diff options
Diffstat (limited to 'tiff/libtiff')
60 files changed, 5622 insertions, 5200 deletions
diff --git a/tiff/libtiff/CMakeLists.txt b/tiff/libtiff/CMakeLists.txt index 080685db..90105b28 100644..100755 --- a/tiff/libtiff/CMakeLists.txt +++ b/tiff/libtiff/CMakeLists.txt @@ -30,97 +30,112 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/tiffconf.h.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/tiffconf.h @ONLY) -extra_dist( - SConstruct - tif_config.h-vms - tif_config.vc.h - tif_config.wince.h - tiffconf.vc.h - tiffconf.wince.h - libtiff.def - libtiff.map - libtiffxx.map) - -set(tiff_HEADERS - tiff.h - tiffio.h - tiffvers.h) - -set(tiff_noinst_HEADERS - t4.h - tif_dir.h - tif_predict.h - tiffiop.h - uvcode.h) - -set(nodist_tiff_HEADERS - ${CMAKE_CURRENT_BINARY_DIR}/tiffconf.h) - -set(tiff_SOURCES - tif_aux.c - tif_close.c - tif_codec.c - tif_color.c - tif_compress.c - tif_dir.c - tif_dirinfo.c - tif_dirread.c - tif_dirwrite.c - tif_dumpmode.c - tif_error.c - tif_extension.c - tif_fax3.c - tif_fax3sm.c - tif_flush.c - tif_getimage.c - tif_jbig.c - tif_jpeg.c - tif_jpeg_12.c - tif_luv.c - tif_lzma.c - tif_lzw.c - tif_next.c - tif_ojpeg.c - tif_open.c - tif_packbits.c - tif_pixarlog.c - tif_predict.c - tif_print.c - tif_read.c - tif_strip.c - tif_swab.c - tif_thunder.c - tif_tile.c - tif_version.c - tif_warning.c - tif_webp.c - tif_write.c - tif_zip.c - tif_zstd.c) - -set(tiffxx_HEADERS - tiffio.hxx) - -set(tiffxx_SOURCES - tif_stream.cxx) +set(tiff_public_HEADERS + tiff.h + tiffio.h + tiffvers.h + ${CMAKE_CURRENT_BINARY_DIR}/tiffconf.h) + +set(tiff_private_HEADERS + t4.h + tif_dir.h + tif_predict.h + tiffiop.h + uvcode.h + ${CMAKE_CURRENT_BINARY_DIR}/tif_config.h) + + +add_library(tiff libtiff.def) + +target_sources(tiff PRIVATE + ${tiff_public_HEADERS} + ${tiff_private_HEADERS} + tif_aux.c + tif_close.c + tif_codec.c + tif_color.c + tif_compress.c + tif_dir.c + tif_dirinfo.c + tif_dirread.c + tif_dirwrite.c + tif_dumpmode.c + tif_error.c + tif_extension.c + tif_fax3.c + tif_fax3sm.c + tif_flush.c + tif_getimage.c + tif_jbig.c + tif_jpeg.c + tif_jpeg_12.c + tif_lerc.c + tif_luv.c + tif_lzma.c + tif_lzw.c + tif_next.c + tif_ojpeg.c + tif_open.c + tif_packbits.c + tif_pixarlog.c + tif_predict.c + tif_print.c + tif_read.c + tif_strip.c + tif_swab.c + tif_thunder.c + tif_tile.c + tif_version.c + tif_warning.c + tif_webp.c + tif_write.c + tif_zip.c + tif_zstd.c) if(USE_WIN32_FILEIO) - extra_dist(tif_unix.c) - list(APPEND tiff_SOURCES tif_win32.c) + target_sources(tiff PRIVATE tif_win32.c) else() - extra_dist(tif_win32.c) - list(APPEND tiff_SOURCES tif_unix.c) + target_sources(tiff PRIVATE tif_unix.c) endif() -add_library(tiff ${tiff_SOURCES} ${tiff_HEADERS} ${nodist_tiff_HEADERS} - ${tiff_port_SOURCES} libtiff.def) target_include_directories(tiff PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}> $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}> + PRIVATE ${TIFF_INCLUDES} ) -target_link_libraries(tiff ${TIFF_LIBRARY_DEPS}) + +if(ZIP_SUPPORT) + target_link_libraries(tiff PRIVATE ZLIB::ZLIB) +endif() +if(ZIP_SUPPORT AND LIBDEFLATE_SUPPORT) + target_link_libraries(tiff PRIVATE Deflate::Deflate) +endif() +if(JPEG_SUPPORT) + target_link_libraries(tiff PRIVATE JPEG::JPEG) + if(JPEG_DUAL_MODE_8_12) + target_include_directories(tiff PRIVATE ${JPEG12_INCLUDE_DIR}) + target_link_libraries(tiff PRIVATE ${JPEG12_LIBRARIES}) + endif() +endif() +if(JBIG_SUPPORT) + target_link_libraries(tiff PRIVATE JBIG::JBIG) +endif() +if(LERC_SUPPORT) + target_link_libraries(tiff PRIVATE LERC::LERC) +endif() +if(LZMA_SUPPORT) + target_link_libraries(tiff PRIVATE LibLZMA::LibLZMA) +endif() +if(ZSTD_SUPPORT) + target_link_libraries(tiff PRIVATE ZSTD::ZSTD) +endif() +if(WEBP_SUPPORT) + target_link_libraries(tiff PRIVATE WebP::WebP) +endif() +target_link_libraries(tiff PRIVATE CMath::CMath) + set_target_properties(tiff PROPERTIES SOVERSION ${SO_COMPATVERSION}) if(NOT CYGWIN) # This property causes shared libraries on Linux to have the full version @@ -139,11 +154,17 @@ install(TARGETS tiff LIBRARY DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR}) -install(FILES ${tiff_HEADERS} ${nodist_tiff_HEADERS} +install(FILES ${tiff_public_HEADERS} DESTINATION "${CMAKE_INSTALL_FULL_INCLUDEDIR}") if(CXX_SUPPORT) - add_library(tiffxx ${tiffxx_SOURCES} ${tiffxx_HEADERS}) + set(tiffxx_HEADERS + tiffio.hxx) + + add_library(tiffxx) + target_sources(tiffxx PRIVATE + ${tiffxx_HEADERS} + tif_stream.cxx) target_link_libraries(tiffxx tiff) set_target_properties(tiffxx PROPERTIES SOVERSION ${SO_COMPATVERSION}) if(NOT CYGWIN) @@ -167,3 +188,13 @@ if(CXX_SUPPORT) DESTINATION "${CMAKE_INSTALL_FULL_INCLUDEDIR}") endif() + +add_executable(mkg3states) +target_sources(mkg3states PRIVATE mkg3states.c tif_fax3.h) +target_link_libraries(mkg3states tiff port) + +add_custom_target(faxtable + DEPENDS mkg3states + COMMAND ${CMAKE_COMMAND} -E rm "tif_fax3sm.c" + COMMAND mkg3states -b -c const "tif_fax3sm.c" + WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}") diff --git a/tiff/libtiff/Makefile.am b/tiff/libtiff/Makefile.am index 14a250a5..44522b62 100644 --- a/tiff/libtiff/Makefile.am +++ b/tiff/libtiff/Makefile.am @@ -29,18 +29,11 @@ libtiffincludedir = $(includedir) EXTRA_DIST = \ CMakeLists.txt \ - Makefile.vc \ - SConstruct \ libtiff.def \ libtiff.map \ libtiffxx.map \ - tif_config.h-vms \ tif_config.h.cmake.in \ - tif_config.vc.h \ - tif_config.wince.h \ - tiffconf.h.cmake.in \ - tiffconf.vc.h \ - tiffconf.wince.h + tiffconf.h.cmake.in libtiffinclude_HEADERS = \ tiff.h \ @@ -81,6 +74,7 @@ libtiff_la_SOURCES = \ tif_jbig.c \ tif_jpeg.c \ tif_jpeg_12.c \ + tif_lerc.c \ tif_luv.c \ tif_lzma.c \ tif_lzw.c \ @@ -128,7 +122,6 @@ endif if HAVE_LD_VERSION_SCRIPT libtiff_la_LDFLAGS += -Wl,--version-script=$(srcdir)/libtiff.map endif -libtiff_la_LIBADD = $(LIBPORT) libtiffxx_la_LDFLAGS = \ -no-undefined \ @@ -139,7 +132,7 @@ endif if HAVE_LD_VERSION_SCRIPT libtiffxx_la_LDFLAGS += -Wl,--version-script=$(srcdir)/libtiffxx.map endif -libtiffxx_la_LIBADD = $(LIBTIFF) $(LIBPORT) +libtiffxx_la_LIBADD = $(LIBTIFF) libtiffxx_la_DEPENDENCIES = libtiff.la # @@ -154,3 +147,4 @@ mkg3states_LDADD = $(LIBPORT) faxtable: mkg3states (rm -f tif_fax3sm.c && ./mkg3states -b -c const tif_fax3sm.c) +AM_CPPFLAGS = -I$(top_srcdir)/libtiff -I$(top_srcdir)/port diff --git a/tiff/libtiff/Makefile.in b/tiff/libtiff/Makefile.in index 2f853ea5..40b78797 100644 --- a/tiff/libtiff/Makefile.in +++ b/tiff/libtiff/Makefile.in @@ -1,7 +1,7 @@ -# Makefile.in generated by automake 1.16.2 from Makefile.am. +# Makefile.in generated by automake 1.16.1 from Makefile.am. # @configure_input@ -# Copyright (C) 1994-2020 Free Software Foundation, Inc. +# Copyright (C) 1994-2018 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -137,7 +137,8 @@ am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ DIST_COMMON = $(srcdir)/Makefile.am $(am__libtiffinclude_HEADERS_DIST) \ $(noinst_HEADERS) $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d -CONFIG_HEADER = tif_config.h tiffconf.h +CONFIG_HEADER = $(top_builddir)/config.h tif_config.h tiffconf.h \ + $(top_builddir)/port/libport_config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = PROGRAMS = $(noinst_PROGRAMS) @@ -172,17 +173,17 @@ am__installdirs = "$(DESTDIR)$(libdir)" \ "$(DESTDIR)$(libtiffincludedir)" \ "$(DESTDIR)$(libtiffincludedir)" LTLIBRARIES = $(lib_LTLIBRARIES) -libtiff_la_DEPENDENCIES = $(LIBPORT) +libtiff_la_LIBADD = am__libtiff_la_SOURCES_DIST = tif_aux.c tif_close.c tif_codec.c \ tif_color.c tif_compress.c tif_dir.c tif_dirinfo.c \ tif_dirread.c tif_dirwrite.c tif_dumpmode.c tif_error.c \ tif_extension.c tif_fax3.c tif_fax3sm.c tif_flush.c \ - tif_getimage.c tif_jbig.c tif_jpeg.c tif_jpeg_12.c tif_luv.c \ - tif_lzma.c tif_lzw.c tif_next.c tif_ojpeg.c tif_open.c \ - tif_packbits.c tif_pixarlog.c tif_predict.c tif_print.c \ - tif_read.c tif_strip.c tif_swab.c tif_thunder.c tif_tile.c \ - tif_version.c tif_warning.c tif_webp.c tif_write.c tif_zip.c \ - tif_zstd.c tif_win32.c tif_unix.c + tif_getimage.c tif_jbig.c tif_jpeg.c tif_jpeg_12.c tif_lerc.c \ + tif_luv.c tif_lzma.c tif_lzw.c tif_next.c tif_ojpeg.c \ + tif_open.c tif_packbits.c tif_pixarlog.c tif_predict.c \ + tif_print.c tif_read.c tif_strip.c tif_swab.c tif_thunder.c \ + tif_tile.c tif_version.c tif_warning.c tif_webp.c tif_write.c \ + tif_zip.c tif_zstd.c tif_win32.c tif_unix.c @WIN32_IO_TRUE@am__objects_1 = tif_win32.lo @WIN32_IO_FALSE@am__objects_2 = tif_unix.lo am_libtiff_la_OBJECTS = tif_aux.lo tif_close.lo tif_codec.lo \ @@ -190,11 +191,11 @@ am_libtiff_la_OBJECTS = tif_aux.lo tif_close.lo tif_codec.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_jpeg_12.lo \ - tif_luv.lo tif_lzma.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_version.lo tif_warning.lo \ - tif_webp.lo tif_write.lo tif_zip.lo tif_zstd.lo \ + tif_lerc.lo tif_luv.lo tif_lzma.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_version.lo \ + tif_warning.lo tif_webp.lo tif_write.lo tif_zip.lo tif_zstd.lo \ $(am__objects_1) $(am__objects_2) libtiff_la_OBJECTS = $(am_libtiff_la_OBJECTS) AM_V_lt = $(am__v_lt_@AM_V@) @@ -225,7 +226,7 @@ AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = -DEFAULT_INCLUDES = -I.@am__isrc@ +DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) -I$(top_builddir)/port depcomp = $(SHELL) $(top_srcdir)/config/depcomp am__maybe_remake_depfiles = depfiles am__depfiles_remade = ./$(DEPDIR)/mkg3states.Po \ @@ -238,19 +239,19 @@ am__depfiles_remade = ./$(DEPDIR)/mkg3states.Po \ ./$(DEPDIR)/tif_fax3.Plo ./$(DEPDIR)/tif_fax3sm.Plo \ ./$(DEPDIR)/tif_flush.Plo ./$(DEPDIR)/tif_getimage.Plo \ ./$(DEPDIR)/tif_jbig.Plo ./$(DEPDIR)/tif_jpeg.Plo \ - ./$(DEPDIR)/tif_jpeg_12.Plo ./$(DEPDIR)/tif_luv.Plo \ - ./$(DEPDIR)/tif_lzma.Plo ./$(DEPDIR)/tif_lzw.Plo \ - ./$(DEPDIR)/tif_next.Plo ./$(DEPDIR)/tif_ojpeg.Plo \ - ./$(DEPDIR)/tif_open.Plo ./$(DEPDIR)/tif_packbits.Plo \ - ./$(DEPDIR)/tif_pixarlog.Plo ./$(DEPDIR)/tif_predict.Plo \ - ./$(DEPDIR)/tif_print.Plo ./$(DEPDIR)/tif_read.Plo \ - ./$(DEPDIR)/tif_stream.Plo ./$(DEPDIR)/tif_strip.Plo \ - ./$(DEPDIR)/tif_swab.Plo ./$(DEPDIR)/tif_thunder.Plo \ - ./$(DEPDIR)/tif_tile.Plo ./$(DEPDIR)/tif_unix.Plo \ - ./$(DEPDIR)/tif_version.Plo ./$(DEPDIR)/tif_warning.Plo \ - ./$(DEPDIR)/tif_webp.Plo ./$(DEPDIR)/tif_win32.Plo \ - ./$(DEPDIR)/tif_write.Plo ./$(DEPDIR)/tif_zip.Plo \ - ./$(DEPDIR)/tif_zstd.Plo + ./$(DEPDIR)/tif_jpeg_12.Plo ./$(DEPDIR)/tif_lerc.Plo \ + ./$(DEPDIR)/tif_luv.Plo ./$(DEPDIR)/tif_lzma.Plo \ + ./$(DEPDIR)/tif_lzw.Plo ./$(DEPDIR)/tif_next.Plo \ + ./$(DEPDIR)/tif_ojpeg.Plo ./$(DEPDIR)/tif_open.Plo \ + ./$(DEPDIR)/tif_packbits.Plo ./$(DEPDIR)/tif_pixarlog.Plo \ + ./$(DEPDIR)/tif_predict.Plo ./$(DEPDIR)/tif_print.Plo \ + ./$(DEPDIR)/tif_read.Plo ./$(DEPDIR)/tif_stream.Plo \ + ./$(DEPDIR)/tif_strip.Plo ./$(DEPDIR)/tif_swab.Plo \ + ./$(DEPDIR)/tif_thunder.Plo ./$(DEPDIR)/tif_tile.Plo \ + ./$(DEPDIR)/tif_unix.Plo ./$(DEPDIR)/tif_version.Plo \ + ./$(DEPDIR)/tif_warning.Plo ./$(DEPDIR)/tif_webp.Plo \ + ./$(DEPDIR)/tif_win32.Plo ./$(DEPDIR)/tif_write.Plo \ + ./$(DEPDIR)/tif_zip.Plo ./$(DEPDIR)/tif_zstd.Plo am__mv = mv -f COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) @@ -301,8 +302,8 @@ am__libtiffinclude_HEADERS_DIST = tiff.h tiffio.h tiffvers.h \ tiffio.hxx HEADERS = $(libtiffinclude_HEADERS) $(nodist_libtiffinclude_HEADERS) \ $(noinst_HEADERS) -am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) \ - tif_config.h.in tiffconf.h.in +am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) \ + $(LISP)tif_config.h.in tiffconf.h.in # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. @@ -463,6 +464,7 @@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ +runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ @@ -475,11 +477,9 @@ top_srcdir = @top_srcdir@ LIBPORT = $(top_builddir)/port/libport.la LIBTIFF = $(top_builddir)/libtiff/libtiff.la libtiffincludedir = $(includedir) -EXTRA_DIST = CMakeLists.txt Makefile.vc SConstruct libtiff.def \ - libtiff.map libtiffxx.map tif_config.h-vms \ - tif_config.h.cmake.in tif_config.vc.h tif_config.wince.h \ - tiffconf.h.cmake.in tiffconf.vc.h tiffconf.wince.h \ - $(am__append_2) $(am__append_4) +EXTRA_DIST = CMakeLists.txt libtiff.def libtiff.map libtiffxx.map \ + tif_config.h.cmake.in tiffconf.h.cmake.in $(am__append_2) \ + $(am__append_4) libtiffinclude_HEADERS = tiff.h tiffio.h tiffvers.h $(am__append_1) noinst_HEADERS = \ t4.h \ @@ -495,8 +495,8 @@ libtiff_la_SOURCES = tif_aux.c tif_close.c tif_codec.c tif_color.c \ tif_compress.c tif_dir.c tif_dirinfo.c tif_dirread.c \ tif_dirwrite.c tif_dumpmode.c tif_error.c tif_extension.c \ tif_fax3.c tif_fax3sm.c tif_flush.c tif_getimage.c tif_jbig.c \ - tif_jpeg.c tif_jpeg_12.c tif_luv.c tif_lzma.c tif_lzw.c \ - tif_next.c tif_ojpeg.c tif_open.c tif_packbits.c \ + tif_jpeg.c tif_jpeg_12.c tif_lerc.c tif_luv.c tif_lzma.c \ + tif_lzw.c tif_next.c tif_ojpeg.c tif_open.c tif_packbits.c \ tif_pixarlog.c tif_predict.c tif_print.c tif_read.c \ tif_strip.c tif_swab.c tif_thunder.c tif_tile.c tif_version.c \ tif_warning.c tif_webp.c tif_write.c tif_zip.c tif_zstd.c \ @@ -507,13 +507,13 @@ libtiffxx_la_SOURCES = \ lib_LTLIBRARIES = libtiff.la $(am__append_6) libtiff_la_LDFLAGS = -no-undefined -version-info \ $(LIBTIFF_VERSION_INFO) $(am__append_7) $(am__append_8) -libtiff_la_LIBADD = $(LIBPORT) libtiffxx_la_LDFLAGS = -no-undefined -version-info \ $(LIBTIFF_VERSION_INFO) $(am__append_9) $(am__append_10) -libtiffxx_la_LIBADD = $(LIBTIFF) $(LIBPORT) +libtiffxx_la_LIBADD = $(LIBTIFF) libtiffxx_la_DEPENDENCIES = libtiff.la mkg3states_SOURCES = mkg3states.c tif_fax3.h mkg3states_LDADD = $(LIBPORT) +AM_CPPFLAGS = -I$(top_srcdir)/libtiff -I$(top_srcdir)/port all: tif_config.h tiffconf.h $(MAKE) $(AM_MAKEFLAGS) all-am @@ -549,28 +549,24 @@ $(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 - @test -f $@ || rm -f stamp-h1 - @test -f $@ || $(MAKE) $(AM_MAKEFLAGS) stamp-h1 - -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) - ($(am__cd) $(top_srcdir) && $(AUTOHEADER)) - rm -f stamp-h1 - touch $@ - -tiffconf.h: stamp-h2 +tif_config.h: stamp-h2 @test -f $@ || rm -f stamp-h2 @test -f $@ || $(MAKE) $(AM_MAKEFLAGS) stamp-h2 -stamp-h2: $(srcdir)/tiffconf.h.in $(top_builddir)/config.status +stamp-h2: $(srcdir)/tif_config.h.in $(top_builddir)/config.status @rm -f stamp-h2 + cd $(top_builddir) && $(SHELL) ./config.status libtiff/tif_config.h + +tiffconf.h: stamp-h3 + @test -f $@ || rm -f stamp-h3 + @test -f $@ || $(MAKE) $(AM_MAKEFLAGS) stamp-h3 + +stamp-h3: $(srcdir)/tiffconf.h.in $(top_builddir)/config.status + @rm -f stamp-h3 cd $(top_builddir) && $(SHELL) ./config.status libtiff/tiffconf.h distclean-hdr: - -rm -f tif_config.h stamp-h1 tiffconf.h stamp-h2 + -rm -f tif_config.h stamp-h2 tiffconf.h stamp-h3 clean-noinstPROGRAMS: @list='$(noinst_PROGRAMS)'; test -n "$$list" || exit 0; \ @@ -652,6 +648,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tif_jbig.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tif_jpeg.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tif_jpeg_12.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tif_lerc.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tif_luv.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tif_lzma.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tif_lzw.Plo@am__quote@ # am--include-marker @@ -922,6 +919,7 @@ distclean: distclean-am -rm -f ./$(DEPDIR)/tif_jbig.Plo -rm -f ./$(DEPDIR)/tif_jpeg.Plo -rm -f ./$(DEPDIR)/tif_jpeg_12.Plo + -rm -f ./$(DEPDIR)/tif_lerc.Plo -rm -f ./$(DEPDIR)/tif_luv.Plo -rm -f ./$(DEPDIR)/tif_lzma.Plo -rm -f ./$(DEPDIR)/tif_lzw.Plo @@ -1012,6 +1010,7 @@ maintainer-clean: maintainer-clean-am -rm -f ./$(DEPDIR)/tif_jbig.Plo -rm -f ./$(DEPDIR)/tif_jpeg.Plo -rm -f ./$(DEPDIR)/tif_jpeg_12.Plo + -rm -f ./$(DEPDIR)/tif_lerc.Plo -rm -f ./$(DEPDIR)/tif_luv.Plo -rm -f ./$(DEPDIR)/tif_lzma.Plo -rm -f ./$(DEPDIR)/tif_lzw.Plo diff --git a/tiff/libtiff/Makefile.vc b/tiff/libtiff/Makefile.vc deleted file mode 100644 index 5aac3310..00000000 --- a/tiff/libtiff/Makefile.vc +++ /dev/null @@ -1,100 +0,0 @@ -# Copyright (C) 2004, Andrey Kiselev <dron@ak4719.spb.edu> -# -# 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. -# -# Makefile for MS Visual C and Watcom C compilers. -# -# To build: -# C:\libtiff\libtiff> nmake /f makefile.vc all -# - -!INCLUDE ..\nmake.opt - -INCL = -I. $(JPEG_INCLUDE) $(ZLIB_INCLUDE) $(JBIG_INCLUDE) - -!IFDEF USE_WIN_CRT_LIB -OBJ_SYSDEP_MODULE = tif_unix.obj -!ELSE -OBJ_SYSDEP_MODULE = tif_win32.obj -!ENDIF - -OBJ = \ - tif_aux.obj \ - tif_close.obj \ - tif_codec.obj \ - tif_color.obj \ - tif_compress.obj \ - tif_dir.obj \ - tif_dirinfo.obj \ - tif_dirread.obj \ - tif_dirwrite.obj \ - tif_dumpmode.obj \ - tif_error.obj \ - tif_extension.obj \ - tif_fax3.obj \ - tif_fax3sm.obj \ - tif_getimage.obj \ - tif_jbig.obj \ - tif_jpeg.obj \ - tif_jpeg_12.obj \ - tif_ojpeg.obj \ - tif_flush.obj \ - tif_luv.obj \ - tif_lzw.obj \ - tif_next.obj \ - tif_open.obj \ - tif_packbits.obj \ - tif_pixarlog.obj \ - tif_predict.obj \ - tif_print.obj \ - tif_read.obj \ - tif_stream.obj \ - tif_swab.obj \ - tif_strip.obj \ - tif_thunder.obj \ - tif_tile.obj \ - tif_version.obj \ - tif_warning.obj \ - tif_write.obj \ - tif_zip.obj \ - $(OBJ_SYSDEP_MODULE) - -all: libtiff.lib $(DLLNAME) - -tif_config.h: tif_config.vc.h - copy tif_config.vc.h tif_config.h - -tiffconf.h: tiffconf.vc.h - copy tiffconf.vc.h tiffconf.h - -libtiff.lib: tif_config.h tiffconf.h $(OBJ) - $(AR) /out:libtiff.lib ..\port\libport.lib $(OBJ) $(LIBS) - -$(DLLNAME): tif_config.h tiffconf.h libtiff.def $(OBJ) - $(LD) /debug /dll /def:libtiff.def /out:$(DLLNAME) \ - /implib:libtiff_i.lib ..\port\libport.lib $(OBJ) $(LIBS) - -clean: - -del tif_config.h tiffconf.h - -del *.obj - -del *.lib - -del *.dll - -del *.dll.manifest - -del *.pdb diff --git a/tiff/libtiff/SConstruct b/tiff/libtiff/SConstruct deleted file mode 100644 index af3daace..00000000 --- a/tiff/libtiff/SConstruct +++ /dev/null @@ -1,71 +0,0 @@ -# Tag Image File Format (TIFF) Software -# -# Copyright (C) 2005, Andrey Kiselev <dron@ak4719.spb.edu> -# -# 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. - -# This file contains rules to build software with the SCons tool -# (see the http://www.scons.org/ for details on SCons). - -# Import globally defined options -Import([ 'env', 'idir_lib' ]) - -SRCS = [ \ - 'tif_aux.c', \ - 'tif_close.c', \ - 'tif_codec.c', \ - 'tif_color.c', \ - 'tif_compress.c', \ - 'tif_dir.c', \ - 'tif_dirinfo.c', \ - 'tif_dirread.c', \ - 'tif_dirwrite.c', \ - 'tif_dumpmode.c', \ - 'tif_error.c', \ - 'tif_extension.c', \ - 'tif_fax3.c', \ - 'tif_fax3sm.c', \ - 'tif_flush.c', \ - 'tif_getimage.c', \ - 'tif_jbig.c', \ - 'tif_jpeg.c', \ - 'tif_luv.c', \ - 'tif_lzw.c', \ - 'tif_next.c', \ - 'tif_ojpeg.c', \ - 'tif_open.c', \ - 'tif_packbits.c', \ - 'tif_pixarlog.c', \ - 'tif_predict.c', \ - 'tif_print.c', \ - 'tif_read.c', \ - 'tif_strip.c', \ - 'tif_swab.c', \ - 'tif_thunder.c', \ - 'tif_tile.c', \ - 'tif_unix.c', \ - 'tif_version.c', \ - 'tif_warning.c', \ - 'tif_write.c', \ - 'tif_zip.c' ] - -StaticLibrary('tiff', SRCS) -SharedLibrary('tiff', SRCS) - diff --git a/tiff/libtiff/mkg3states.c b/tiff/libtiff/mkg3states.c index 2cb9174c..44653255 100644 --- a/tiff/libtiff/mkg3states.c +++ b/tiff/libtiff/mkg3states.c @@ -28,6 +28,7 @@ * Copyright (C) 1990, 1995 Frank D. Cringle. */ #include "tif_config.h" +#include "libport.h" #include <stdio.h> #include <stdlib.h> @@ -39,10 +40,6 @@ #include "tif_fax3.h" -#ifndef HAVE_GETOPT -extern int getopt(int argc, char * const argv[], const char *optstring); -#endif - #define streq(a,b) (strcmp(a,b) == 0) /* NB: can't use names in tif_fax3.h 'cuz they are declared const */ @@ -51,8 +48,8 @@ TIFFFaxTabEnt WhiteTable[4096]; TIFFFaxTabEnt BlackTable[8192]; struct proto { - uint16 code; /* right justified, lsb-first, zero filled */ - uint16 val; /* (pixel count)<<4 + code width */ + uint16_t code; /* right justified, lsb-first, zero filled */ + uint16_t val; /* (pixel count)<<4 + code width */ }; static struct proto Pass[] = { @@ -433,11 +430,19 @@ main(int argc, char* argv[]) fprintf(fd, "/* WARNING, this file was automatically generated by the\n"); fprintf(fd, " mkg3states program */\n"); + fprintf(fd, "#include <stdint.h>\n"); fprintf(fd, "#include \"tiff.h\"\n"); fprintf(fd, "#include \"tif_fax3.h\"\n"); WriteTable(fd, MainTable, 128, "TIFFFaxMainTable"); WriteTable(fd, WhiteTable, 4096, "TIFFFaxWhiteTable"); WriteTable(fd, BlackTable, 8192, "TIFFFaxBlackTable"); + fprintf(fd, "/*\n" + " * Local Variables:\n" + " * mode: c\n" + " * c-basic-offset: 8\n" + " * fill-column: 78\n" + " * End:\n" + " */\n"); fclose(fd); return (0); } diff --git a/tiff/libtiff/tif_aux.c b/tiff/libtiff/tif_aux.c index c9f19054..140f26c7 100644 --- a/tiff/libtiff/tif_aux.c +++ b/tiff/libtiff/tif_aux.c @@ -32,10 +32,10 @@ #include <math.h> #include <float.h> -uint32 -_TIFFMultiply32(TIFF* tif, uint32 first, uint32 second, const char* where) +uint32_t +_TIFFMultiply32(TIFF* tif, uint32_t first, uint32_t second, const char* where) { - if (second && first > TIFF_UINT32_MAX / second) { + if (second && first > UINT32_MAX / second) { TIFFErrorExt(tif->tif_clientdata, where, "Integer overflow in %s", where); return 0; } @@ -43,10 +43,10 @@ _TIFFMultiply32(TIFF* tif, uint32 first, uint32 second, const char* where) return first * second; } -uint64 -_TIFFMultiply64(TIFF* tif, uint64 first, uint64 second, const char* where) +uint64_t +_TIFFMultiply64(TIFF* tif, uint64_t first, uint64_t second, const char* where) { - if (second && first > TIFF_UINT64_MAX / second) { + if (second && first > UINT64_MAX / second) { TIFFErrorExt(tif->tif_clientdata, where, "Integer overflow in %s", where); return 0; } @@ -79,9 +79,9 @@ _TIFFMultiplySSize(TIFF* tif, tmsize_t first, tmsize_t second, const char* where return first * second; } -tmsize_t _TIFFCastUInt64ToSSize(TIFF* tif, uint64 val, const char* module) +tmsize_t _TIFFCastUInt64ToSSize(TIFF* tif, uint64_t val, const char* module) { - if( val > (uint64)TIFF_TMSIZE_T_MAX ) + if( val > (uint64_t)TIFF_TMSIZE_T_MAX ) { if( tif != NULL && module != NULL ) { @@ -109,8 +109,8 @@ _TIFFCheckRealloc(TIFF* tif, void* buffer, if (cp == NULL) { TIFFErrorExt(tif->tif_clientdata, tif->tif_name, "Failed to allocate memory for %s " - "(%ld elements of %ld bytes each)", - what,(long) nmemb, (long) elem_size); + "(%"TIFF_SSIZE_FORMAT" elements of %"TIFF_SSIZE_FORMAT" bytes each)", + what, nmemb, elem_size); } return cp; @@ -125,7 +125,7 @@ _TIFFCheckMalloc(TIFF* tif, tmsize_t nmemb, tmsize_t elem_size, const char* what static int TIFFDefaultTransferFunction(TIFFDirectory* td) { - uint16 **tf = td->td_transferfunction; + uint16_t **tf = td->td_transferfunction; tmsize_t i, n, nbytes; tf[0] = tf[1] = tf[2] = 0; @@ -133,22 +133,22 @@ TIFFDefaultTransferFunction(TIFFDirectory* td) return 0; n = ((tmsize_t)1)<<td->td_bitspersample; - nbytes = n * sizeof (uint16); - tf[0] = (uint16 *)_TIFFmalloc(nbytes); + nbytes = n * sizeof (uint16_t); + tf[0] = (uint16_t *)_TIFFmalloc(nbytes); if (tf[0] == NULL) return 0; tf[0][0] = 0; for (i = 1; i < n; i++) { double t = (double)i/((double) n-1.); - tf[0][i] = (uint16)floor(65535.*pow(t, 2.2) + .5); + tf[0][i] = (uint16_t)floor(65535. * pow(t, 2.2) + .5); } if (td->td_samplesperpixel - td->td_extrasamples > 1) { - tf[1] = (uint16 *)_TIFFmalloc(nbytes); + tf[1] = (uint16_t *)_TIFFmalloc(nbytes); if(tf[1] == NULL) goto bad; _TIFFmemcpy(tf[1], tf[0], nbytes); - tf[2] = (uint16 *)_TIFFmalloc(nbytes); + tf[2] = (uint16_t *)_TIFFmalloc(nbytes); if (tf[2] == NULL) goto bad; _TIFFmemcpy(tf[2], tf[0], nbytes); @@ -205,7 +205,7 @@ TIFFDefaultRefBlackWhite(TIFFDirectory* td) * place in the library -- in TIFFDefaultDirectory. */ int -TIFFVGetFieldDefaulted(TIFF* tif, uint32 tag, va_list ap) +TIFFVGetFieldDefaulted(TIFF* tif, uint32_t tag, va_list ap) { TIFFDirectory *td = &tif->tif_dir; @@ -213,37 +213,37 @@ TIFFVGetFieldDefaulted(TIFF* tif, uint32 tag, va_list ap) return (1); switch (tag) { case TIFFTAG_SUBFILETYPE: - *va_arg(ap, uint32 *) = td->td_subfiletype; + *va_arg(ap, uint32_t *) = td->td_subfiletype; return (1); case TIFFTAG_BITSPERSAMPLE: - *va_arg(ap, uint16 *) = td->td_bitspersample; + *va_arg(ap, uint16_t *) = td->td_bitspersample; return (1); case TIFFTAG_THRESHHOLDING: - *va_arg(ap, uint16 *) = td->td_threshholding; + *va_arg(ap, uint16_t *) = td->td_threshholding; return (1); case TIFFTAG_FILLORDER: - *va_arg(ap, uint16 *) = td->td_fillorder; + *va_arg(ap, uint16_t *) = td->td_fillorder; return (1); case TIFFTAG_ORIENTATION: - *va_arg(ap, uint16 *) = td->td_orientation; + *va_arg(ap, uint16_t *) = td->td_orientation; return (1); case TIFFTAG_SAMPLESPERPIXEL: - *va_arg(ap, uint16 *) = td->td_samplesperpixel; + *va_arg(ap, uint16_t *) = td->td_samplesperpixel; return (1); case TIFFTAG_ROWSPERSTRIP: - *va_arg(ap, uint32 *) = td->td_rowsperstrip; + *va_arg(ap, uint32_t *) = td->td_rowsperstrip; return (1); case TIFFTAG_MINSAMPLEVALUE: - *va_arg(ap, uint16 *) = td->td_minsamplevalue; + *va_arg(ap, uint16_t *) = td->td_minsamplevalue; return (1); case TIFFTAG_MAXSAMPLEVALUE: - *va_arg(ap, uint16 *) = td->td_maxsamplevalue; + *va_arg(ap, uint16_t *) = td->td_maxsamplevalue; return (1); case TIFFTAG_PLANARCONFIG: - *va_arg(ap, uint16 *) = td->td_planarconfig; + *va_arg(ap, uint16_t *) = td->td_planarconfig; return (1); case TIFFTAG_RESOLUTIONUNIT: - *va_arg(ap, uint16 *) = td->td_resolutionunit; + *va_arg(ap, uint16_t *) = td->td_resolutionunit; return (1); case TIFFTAG_PREDICTOR: { @@ -252,42 +252,42 @@ TIFFVGetFieldDefaulted(TIFF* tif, uint32 tag, va_list ap) { TIFFErrorExt(tif->tif_clientdata, tif->tif_name, "Cannot get \"Predictor\" tag as plugin is not configured"); - *va_arg(ap, uint16*) = 0; + *va_arg(ap, uint16_t*) = 0; return 0; } - *va_arg(ap, uint16*) = (uint16) sp->predictor; + *va_arg(ap, uint16_t*) = (uint16_t) sp->predictor; return 1; } case TIFFTAG_DOTRANGE: - *va_arg(ap, uint16 *) = 0; - *va_arg(ap, uint16 *) = (1<<td->td_bitspersample)-1; + *va_arg(ap, uint16_t *) = 0; + *va_arg(ap, uint16_t *) = (1 << td->td_bitspersample) - 1; return (1); case TIFFTAG_INKSET: - *va_arg(ap, uint16 *) = INKSET_CMYK; + *va_arg(ap, uint16_t *) = INKSET_CMYK; return 1; case TIFFTAG_NUMBEROFINKS: - *va_arg(ap, uint16 *) = 4; + *va_arg(ap, uint16_t *) = 4; return (1); case TIFFTAG_EXTRASAMPLES: - *va_arg(ap, uint16 *) = td->td_extrasamples; - *va_arg(ap, const uint16 **) = td->td_sampleinfo; + *va_arg(ap, uint16_t *) = td->td_extrasamples; + *va_arg(ap, const uint16_t **) = td->td_sampleinfo; return (1); case TIFFTAG_MATTEING: - *va_arg(ap, uint16 *) = + *va_arg(ap, uint16_t *) = (td->td_extrasamples == 1 && td->td_sampleinfo[0] == EXTRASAMPLE_ASSOCALPHA); return (1); case TIFFTAG_TILEDEPTH: - *va_arg(ap, uint32 *) = td->td_tiledepth; + *va_arg(ap, uint32_t *) = td->td_tiledepth; return (1); case TIFFTAG_DATATYPE: - *va_arg(ap, uint16 *) = td->td_sampleformat-1; + *va_arg(ap, uint16_t *) = td->td_sampleformat - 1; return (1); case TIFFTAG_SAMPLEFORMAT: - *va_arg(ap, uint16 *) = td->td_sampleformat; + *va_arg(ap, uint16_t *) = td->td_sampleformat; return(1); case TIFFTAG_IMAGEDEPTH: - *va_arg(ap, uint32 *) = td->td_imagedepth; + *va_arg(ap, uint32_t *) = td->td_imagedepth; return (1); case TIFFTAG_YCBCRCOEFFICIENTS: { @@ -297,11 +297,11 @@ TIFFVGetFieldDefaulted(TIFF* tif, uint32 tag, va_list ap) return 1; } case TIFFTAG_YCBCRSUBSAMPLING: - *va_arg(ap, uint16 *) = td->td_ycbcrsubsampling[0]; - *va_arg(ap, uint16 *) = td->td_ycbcrsubsampling[1]; + *va_arg(ap, uint16_t *) = td->td_ycbcrsubsampling[0]; + *va_arg(ap, uint16_t *) = td->td_ycbcrsubsampling[1]; return (1); case TIFFTAG_YCBCRPOSITIONING: - *va_arg(ap, uint16 *) = td->td_ycbcrpositioning; + *va_arg(ap, uint16_t *) = td->td_ycbcrpositioning; return (1); case TIFFTAG_WHITEPOINT: { @@ -321,10 +321,10 @@ TIFFVGetFieldDefaulted(TIFF* tif, uint32 tag, va_list ap) TIFFErrorExt(tif->tif_clientdata, tif->tif_name, "No space for \"TransferFunction\" tag"); return (0); } - *va_arg(ap, const uint16 **) = td->td_transferfunction[0]; + *va_arg(ap, const uint16_t **) = td->td_transferfunction[0]; if (td->td_samplesperpixel - td->td_extrasamples > 1) { - *va_arg(ap, const uint16 **) = td->td_transferfunction[1]; - *va_arg(ap, const uint16 **) = td->td_transferfunction[2]; + *va_arg(ap, const uint16_t **) = td->td_transferfunction[1]; + *va_arg(ap, const uint16_t **) = td->td_transferfunction[2]; } return (1); case TIFFTAG_REFERENCEBLACKWHITE: @@ -341,7 +341,7 @@ TIFFVGetFieldDefaulted(TIFF* tif, uint32 tag, va_list ap) * value if the tag is not present in the directory. */ int -TIFFGetFieldDefaulted(TIFF* tif, uint32 tag, ...) +TIFFGetFieldDefaulted(TIFF* tif, uint32_t tag, ...) { int ok; va_list ap; @@ -353,16 +353,16 @@ TIFFGetFieldDefaulted(TIFF* tif, uint32 tag, ...) } struct _Int64Parts { - int32 low, high; + int32_t low, high; }; typedef union { struct _Int64Parts part; - int64 value; + int64_t value; } _Int64; float -_TIFFUInt64ToFloat(uint64 ui64) +_TIFFUInt64ToFloat(uint64_t ui64) { _Int64 i; @@ -378,7 +378,7 @@ _TIFFUInt64ToFloat(uint64 ui64) } double -_TIFFUInt64ToDouble(uint64 ui64) +_TIFFUInt64ToDouble(uint64_t ui64) { _Int64 i; @@ -406,7 +406,7 @@ int _TIFFSeekOK(TIFF* tif, toff_t off) { /* Huge offsets, especially -1 / UINT64_MAX, can cause issues */ /* See http://bugzilla.maptools.org/show_bug.cgi?id=2726 */ - return off <= (~(uint64)0)/2 && TIFFSeekFile(tif,off,SEEK_SET)==off; + return off <= (~(uint64_t)0) / 2 && TIFFSeekFile(tif, off, SEEK_SET) == off; } /* vim: set ts=8 sts=8 sw=8 noet: */ diff --git a/tiff/libtiff/tif_close.c b/tiff/libtiff/tif_close.c index e4228df9..674518a1 100644 --- a/tiff/libtiff/tif_close.c +++ b/tiff/libtiff/tif_close.c @@ -76,7 +76,7 @@ TIFFCleanup(TIFF* tif) * Clean up custom fields. */ if (tif->tif_fields && tif->tif_nfields > 0) { - uint32 i; + uint32_t i; for (i = 0; i < tif->tif_nfields; i++) { TIFFField *fld = tif->tif_fields[i]; @@ -91,7 +91,7 @@ TIFFCleanup(TIFF* tif) } if (tif->tif_nfieldscompat > 0) { - uint32 i; + uint32_t i; for (i = 0; i < tif->tif_nfieldscompat; i++) { if (tif->tif_fieldscompat[i].allocated_size) diff --git a/tiff/libtiff/tif_codec.c b/tiff/libtiff/tif_codec.c index b6c04f01..931eb093 100644 --- a/tiff/libtiff/tif_codec.c +++ b/tiff/libtiff/tif_codec.c @@ -67,6 +67,9 @@ static int NotConfigured(TIFF*, int); #ifndef LOGLUV_SUPPORT #define TIFFInitSGILog NotConfigured #endif +#ifndef LERC_SUPPORT +#define TIFFInitLERC NotConfigured +#endif #ifndef LZMA_SUPPORT #define TIFFInitLZMA NotConfigured #endif @@ -80,11 +83,7 @@ static int NotConfigured(TIFF*, int); /* * Compression schemes statically built into the library. */ -#ifdef VMS const TIFFCodec _TIFFBuiltinCODECS[] = { -#else -TIFFCodec _TIFFBuiltinCODECS[] = { -#endif { "None", COMPRESSION_NONE, TIFFInitDumpMode }, { "LZW", COMPRESSION_LZW, TIFFInitLZW }, { "PackBits", COMPRESSION_PACKBITS, TIFFInitPackBits }, @@ -105,6 +104,7 @@ TIFFCodec _TIFFBuiltinCODECS[] = { { "LZMA", COMPRESSION_LZMA, TIFFInitLZMA }, { "ZSTD", COMPRESSION_ZSTD, TIFFInitZSTD }, { "WEBP", COMPRESSION_WEBP, TIFFInitWebP }, + { "LERC", COMPRESSION_LERC, TIFFInitLERC }, { NULL, 0, NULL } }; @@ -114,7 +114,7 @@ _notConfigured(TIFF* tif) const TIFFCodec* c = TIFFFindCODEC(tif->tif_dir.td_compression); char compression_code[20]; - sprintf(compression_code, "%d",tif->tif_dir.td_compression ); + sprintf(compression_code, "%"PRIu16, tif->tif_dir.td_compression ); TIFFErrorExt(tif->tif_clientdata, tif->tif_name, "%s compression support is not configured", c ? c->name : compression_code ); @@ -146,7 +146,7 @@ NotConfigured(TIFF* tif, int scheme) */ int -TIFFIsCODECConfigured(uint16 scheme) +TIFFIsCODECConfigured(uint16_t scheme) { const TIFFCodec* codec = TIFFFindCODEC(scheme); diff --git a/tiff/libtiff/tif_color.c b/tiff/libtiff/tif_color.c index 8fae40ea..2b962af9 100644 --- a/tiff/libtiff/tif_color.c +++ b/tiff/libtiff/tif_color.c @@ -41,8 +41,8 @@ * Convert color value from the CIE L*a*b* 1976 space to CIE XYZ. */ void -TIFFCIELabToXYZ(TIFFCIELabToRGB *cielab, uint32 l, int32 a, int32 b, - float *X, float *Y, float *Z) +TIFFCIELabToXYZ(TIFFCIELabToRGB *cielab, uint32_t l, int32_t a, int32_t b, + float *X, float *Y, float *Z) { float L = (float)l * 100.0F / 255.0F; float cby, tmp; @@ -68,13 +68,13 @@ TIFFCIELabToXYZ(TIFFCIELabToRGB *cielab, uint32 l, int32 a, int32 b, *Z = cielab->Z0 * tmp * tmp * tmp; } -#define RINT(R) ((uint32)((R)>0?((R)+0.5):((R)-0.5))) +#define RINT(R) ((uint32_t)((R)>0?((R)+0.5):((R)-0.5))) /* * Convert color value from the XYZ space to RGB. */ void TIFFXYZToRGB(TIFFCIELabToRGB *cielab, float X, float Y, float Z, - uint32 *r, uint32 *g, uint32 *b) + uint32_t *r, uint32_t *g, uint32_t *b) { int i; float Yr, Yg, Yb; @@ -171,17 +171,17 @@ TIFFCIELabToRGBInit(TIFFCIELabToRGB* cielab, * see below for more information on how it works. */ #define SHIFT 16 -#define FIX(x) ((int32)((x) * (1L<<SHIFT) + 0.5)) -#define ONE_HALF ((int32)(1<<(SHIFT-1))) -#define Code2V(c, RB, RW, CR) ((((c)-(int32)(RB))*(float)(CR))/(float)(((RW)-(RB)!=0) ? ((RW)-(RB)) : 1)) +#define FIX(x) ((int32_t)((x) * (1L<<SHIFT) + 0.5)) +#define ONE_HALF ((int32_t)(1<<(SHIFT-1))) +#define Code2V(c, RB, RW, CR) ((((c)-(int32_t)(RB))*(float)(CR))/(float)(((RW)-(RB)!=0) ? ((RW)-(RB)) : 1)) #define CLAMP(f,min,max) ((f)<(min)?(min):(f)>(max)?(max):(f)) #define HICLAMP(f,max) ((f)>(max)?(max):(f)) void -TIFFYCbCrtoRGB(TIFFYCbCrToRGB *ycbcr, uint32 Y, int32 Cb, int32 Cr, - uint32 *r, uint32 *g, uint32 *b) +TIFFYCbCrtoRGB(TIFFYCbCrToRGB *ycbcr, uint32_t Y, int32_t Cb, int32_t Cr, + uint32_t *r, uint32_t *g, uint32_t *b) { - int32 i; + int32_t i; /* XXX: Only 8-bit YCbCr input supported for now */ Y = HICLAMP(Y, 255); @@ -241,7 +241,7 @@ TIFFYCbCrToRGBInit(TIFFYCbCrToRGB* ycbcr, float *luma, float *refBlackWhite) #define LumaBlue luma[2] clamptab = (TIFFRGBValue*)( - (uint8*) ycbcr+TIFFroundup_32(sizeof (TIFFYCbCrToRGB), sizeof (long))); + (uint8_t*) ycbcr + TIFFroundup_32(sizeof (TIFFYCbCrToRGB), sizeof (long))); _TIFFmemset(clamptab, 0, 256); /* v < 0 => 0 */ ycbcr->clamptab = (clamptab += 256); for (i = 0; i < 256; i++) @@ -249,14 +249,14 @@ TIFFYCbCrToRGBInit(TIFFYCbCrToRGB* ycbcr, float *luma, float *refBlackWhite) _TIFFmemset(clamptab+256, 255, 2*256); /* v > 255 => 255 */ ycbcr->Cr_r_tab = (int*) (clamptab + 3*256); ycbcr->Cb_b_tab = ycbcr->Cr_r_tab + 256; - ycbcr->Cr_g_tab = (int32*) (ycbcr->Cb_b_tab + 256); + ycbcr->Cr_g_tab = (int32_t*) (ycbcr->Cb_b_tab + 256); ycbcr->Cb_g_tab = ycbcr->Cr_g_tab + 256; ycbcr->Y_tab = ycbcr->Cb_g_tab + 256; - { float f1 = 2-2*LumaRed; int32 D1 = FIX(CLAMP(f1,0.0F,2.0F)); - float f2 = LumaRed*f1/LumaGreen; int32 D2 = -FIX(CLAMP(f2,0.0F,2.0F)); - float f3 = 2-2*LumaBlue; int32 D3 = FIX(CLAMP(f3,0.0F,2.0F)); - float f4 = LumaBlue*f3/LumaGreen; int32 D4 = -FIX(CLAMP(f4,0.0F,2.0F)); + { float f1 = 2-2*LumaRed; int32_t D1 = FIX(CLAMP(f1, 0.0F, 2.0F)); + float f2 = LumaRed*f1/LumaGreen; int32_t D2 = -FIX(CLAMP(f2, 0.0F, 2.0F)); + float f3 = 2-2*LumaBlue; int32_t D3 = FIX(CLAMP(f3, 0.0F, 2.0F)); + float f4 = LumaBlue*f3/LumaGreen; int32_t D4 = -FIX(CLAMP(f4, 0.0F, 2.0F)); int x; #undef LumaBlue @@ -271,19 +271,19 @@ TIFFYCbCrToRGBInit(TIFFYCbCrToRGB* ycbcr, float *luma, float *refBlackWhite) * constructing tables indexed by the raw pixel data. */ for (i = 0, x = -128; i < 256; i++, x++) { - int32 Cr = (int32)CLAMPw(Code2V(x, refBlackWhite[4] - 128.0F, + int32_t Cr = (int32_t)CLAMPw(Code2V(x, refBlackWhite[4] - 128.0F, refBlackWhite[5] - 128.0F, 127), -128.0F * 32, 128.0F * 32); - int32 Cb = (int32)CLAMPw(Code2V(x, refBlackWhite[2] - 128.0F, + int32_t Cb = (int32_t)CLAMPw(Code2V(x, refBlackWhite[2] - 128.0F, refBlackWhite[3] - 128.0F, 127), -128.0F * 32, 128.0F * 32); - ycbcr->Cr_r_tab[i] = (int32)((D1*Cr + ONE_HALF)>>SHIFT); - ycbcr->Cb_b_tab[i] = (int32)((D3*Cb + ONE_HALF)>>SHIFT); + ycbcr->Cr_r_tab[i] = (int32_t)((D1 * Cr + ONE_HALF) >> SHIFT); + ycbcr->Cb_b_tab[i] = (int32_t)((D3 * Cb + ONE_HALF) >> SHIFT); ycbcr->Cr_g_tab[i] = D2*Cr; ycbcr->Cb_g_tab[i] = D4*Cb + ONE_HALF; ycbcr->Y_tab[i] = - (int32)CLAMPw(Code2V(x + 128, refBlackWhite[0], refBlackWhite[1], 255), + (int32_t)CLAMPw(Code2V(x + 128, refBlackWhite[0], refBlackWhite[1], 255), -128.0F * 32, 128.0F * 32); } } diff --git a/tiff/libtiff/tif_compress.c b/tiff/libtiff/tif_compress.c index 915478f5..8fcedf45 100644 --- a/tiff/libtiff/tif_compress.c +++ b/tiff/libtiff/tif_compress.c @@ -40,28 +40,28 @@ TIFFNoEncode(TIFF* tif, const char* method) c->name, method); } else { TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "Compression scheme %u %s encoding is not implemented", + "Compression scheme %"PRIu16" %s encoding is not implemented", tif->tif_dir.td_compression, method); } return (-1); } int -_TIFFNoRowEncode(TIFF* tif, uint8* pp, tmsize_t cc, uint16 s) +_TIFFNoRowEncode(TIFF* tif, uint8_t* pp, tmsize_t cc, uint16_t s) { (void) pp; (void) cc; (void) s; return (TIFFNoEncode(tif, "scanline")); } int -_TIFFNoStripEncode(TIFF* tif, uint8* pp, tmsize_t cc, uint16 s) +_TIFFNoStripEncode(TIFF* tif, uint8_t* pp, tmsize_t cc, uint16_t s) { (void) pp; (void) cc; (void) s; return (TIFFNoEncode(tif, "strip")); } int -_TIFFNoTileEncode(TIFF* tif, uint8* pp, tmsize_t cc, uint16 s) +_TIFFNoTileEncode(TIFF* tif, uint8_t* pp, tmsize_t cc, uint16_t s) { (void) pp; (void) cc; (void) s; return (TIFFNoEncode(tif, "tile")); @@ -78,7 +78,7 @@ TIFFNoDecode(TIFF* tif, const char* method) c->name, method); else TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "Compression scheme %u %s decoding is not implemented", + "Compression scheme %"PRIu16" %s decoding is not implemented", tif->tif_dir.td_compression, method); return (0); } @@ -91,28 +91,28 @@ _TIFFNoFixupTags(TIFF* tif) } int -_TIFFNoRowDecode(TIFF* tif, uint8* pp, tmsize_t cc, uint16 s) +_TIFFNoRowDecode(TIFF* tif, uint8_t* pp, tmsize_t cc, uint16_t s) { (void) pp; (void) cc; (void) s; return (TIFFNoDecode(tif, "scanline")); } int -_TIFFNoStripDecode(TIFF* tif, uint8* pp, tmsize_t cc, uint16 s) +_TIFFNoStripDecode(TIFF* tif, uint8_t* pp, tmsize_t cc, uint16_t s) { (void) pp; (void) cc; (void) s; return (TIFFNoDecode(tif, "strip")); } int -_TIFFNoTileDecode(TIFF* tif, uint8* pp, tmsize_t cc, uint16 s) +_TIFFNoTileDecode(TIFF* tif, uint8_t* pp, tmsize_t cc, uint16_t s) { (void) pp; (void) cc; (void) s; return (TIFFNoDecode(tif, "tile")); } int -_TIFFNoSeek(TIFF* tif, uint32 off) +_TIFFNoSeek(TIFF* tif, uint32_t off) { (void) off; TIFFErrorExt(tif->tif_clientdata, tif->tif_name, @@ -121,7 +121,7 @@ _TIFFNoSeek(TIFF* tif, uint32 off) } int -_TIFFNoPreCode(TIFF* tif, uint16 s) +_TIFFNoPreCode(TIFF* tif, uint16_t s) { (void) tif; (void) s; return (1); @@ -158,7 +158,7 @@ _TIFFSetDefaultCompressionState(TIFF* tif) int TIFFSetCompressionScheme(TIFF* tif, int scheme) { - const TIFFCodec *c = TIFFFindCODEC((uint16) scheme); + const TIFFCodec *c = TIFFFindCODEC((uint16_t) scheme); _TIFFSetDefaultCompressionState(tif); /* @@ -182,7 +182,7 @@ typedef struct _codec { static codec_t* registeredCODECS = NULL; const TIFFCodec* -TIFFFindCODEC(uint16 scheme) +TIFFFindCODEC(uint16_t scheme) { const TIFFCodec* c; codec_t* cd; @@ -197,15 +197,15 @@ TIFFFindCODEC(uint16 scheme) } TIFFCodec* -TIFFRegisterCODEC(uint16 scheme, const char* name, TIFFInitMethod init) +TIFFRegisterCODEC(uint16_t scheme, const char* name, TIFFInitMethod init) { codec_t* cd = (codec_t*) _TIFFmalloc((tmsize_t)(sizeof (codec_t) + sizeof (TIFFCodec) + strlen(name)+1)); if (cd != NULL) { - cd->info = (TIFFCodec*) ((uint8*) cd + sizeof (codec_t)); + cd->info = (TIFFCodec*) ((uint8_t*) cd + sizeof (codec_t)); cd->info->name = (char*) - ((uint8*) cd->info + sizeof (TIFFCodec)); + ((uint8_t*) cd->info + sizeof (TIFFCodec)); strcpy(cd->info->name, name); cd->info->scheme = scheme; cd->info->init = init; diff --git a/tiff/libtiff/tif_config.h-vms b/tiff/libtiff/tif_config.h-vms deleted file mode 100644 index d653bd82..00000000 --- a/tiff/libtiff/tif_config.h-vms +++ /dev/null @@ -1,46 +0,0 @@ -/* 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 diff --git a/tiff/libtiff/tif_config.h.cmake.in b/tiff/libtiff/tif_config.h.cmake.in index 24144603..20e44630 100644 --- a/tiff/libtiff/tif_config.h.cmake.in +++ b/tiff/libtiff/tif_config.h.cmake.in @@ -1,6 +1,8 @@ /* libtiff/tif_config.h.cmake.in. Not generated, but originated from autoheader. */ /* This file must be kept up-to-date with needed substitutions from libtiff/tif_config.h.in. */ +#include "tiffconf.h" + /* Support CCITT Group 3 & 4 algorithms */ #cmakedefine CCITT_SUPPORT 1 @@ -20,12 +22,15 @@ /* Define to 1 if you have the <assert.h> header file. */ #cmakedefine HAVE_ASSERT_H 1 -/* Define to 1 if you have the <dlfcn.h> header file. */ -#cmakedefine HAVE_DLFCN_H 1 +/* Define to 1 if you have the declaration of `optarg', and to 0 if you don't. */ +#cmakedefine HAVE_DECL_OPTARG 1 /* Define to 1 if you have the <fcntl.h> header file. */ #cmakedefine HAVE_FCNTL_H 1 +/* Define to 1 if fseeko (and presumably ftello) exists and is declared. */ +#cmakedefine HAVE_FSEEKO 1 + /* Define to 1 if you have the `getopt' function. */ #cmakedefine HAVE_GETOPT 1 @@ -41,18 +46,12 @@ /* Define to 1 if you have the <GL/gl.h> header file. */ #cmakedefine HAVE_GL_GL_H 1 -/* Define to 1 if you have the <inttypes.h> header file. */ -#cmakedefine HAVE_INTTYPES_H 1 - /* Define to 1 if you have the <io.h> header file. */ #cmakedefine HAVE_IO_H 1 /* Define to 1 if you have the `jbg_newlen' function. */ #cmakedefine HAVE_JBG_NEWLEN 1 -/* Define to 1 if you have the `lfind' function. */ -#cmakedefine HAVE_LFIND 1 - /* Define to 1 if you have the `mmap' function. */ #cmakedefine HAVE_MMAP 1 @@ -62,42 +61,12 @@ /* Define to 1 if you have the <OpenGL/gl.h> header file. */ #cmakedefine HAVE_OPENGL_GL_H 1 -/* Define to 1 if you have the <search.h> header file. */ -#cmakedefine HAVE_SEARCH_H 1 - /* Define to 1 if you have the `setmode' function. */ #cmakedefine HAVE_SETMODE 1 -/* Define to 1 if you have the `snprintf' function. */ -#cmakedefine HAVE_SNPRINTF 1 - -/* Define to 1 if you have the <stdint.h> header file. */ -#cmakedefine HAVE_STDINT_H 1 - -/* Define to 1 if you have the `strcasecmp' function. */ -#cmakedefine HAVE_STRCASECMP 1 - /* Define to 1 if you have the <strings.h> header file. */ #cmakedefine HAVE_STRINGS_H 1 -/* Define to 1 if you have the <string.h> header file. */ -#cmakedefine HAVE_STRING_H 1 - -/* Define to 1 if you have the `strtol' function. */ -#cmakedefine HAVE_STRTOL 1 - -/* Define to 1 if you have the `strtoll' function. */ -#cmakedefine HAVE_STRTOLL 1 - -/* Define to 1 if you have the `strtoul' function. */ -#cmakedefine HAVE_STRTOUL 1 - -/* Define to 1 if you have the `strtoull' function. */ -#cmakedefine HAVE_STRTOULL 1 - -/* Define to 1 if you have the <sys/time.h> header file. */ -#cmakedefine HAVE_SYS_TIME_H 1 - /* Define to 1 if you have the <sys/types.h> header file. */ #cmakedefine HAVE_SYS_TYPES_H 1 @@ -105,20 +74,17 @@ #cmakedefine HAVE_UNISTD_H 1 /* 8/12 bit libjpeg dual mode enabled */ -#cmakedefine JPEG_DUAL_MODE_8_12 1 +#cmakedefine JPEG_DUAL_MODE_8_12 1 1 + +/* Support LERC compression */ +#cmakedefine LERC_SUPPORT 1 /* 12bit libjpeg primary include file with path */ -#define LIBJPEG_12_PATH @LIBJPEG_12_PATH@ +#define LIBJPEG_12_PATH "@LIBJPEG_12_PATH@" /* Support LZMA2 compression */ #cmakedefine LZMA_SUPPORT 1 -/* Support ZSTD compression */ -#cmakedefine ZSTD_SUPPORT 1 - -/* Support WEBP compression */ -#cmakedefine WEBP_SUPPORT 1 - /* Name of package */ #define PACKAGE "@PACKAGE_NAME@" @@ -140,69 +106,25 @@ /* Define to the version of this package. */ #define PACKAGE_VERSION "@PACKAGE_VERSION@" -/* The size of `signed int', as computed by sizeof. */ -#define SIZEOF_SIGNED_INT @SIZEOF_SIGNED_INT@ - -/* The size of `signed long', as computed by sizeof. */ -#define SIZEOF_SIGNED_LONG @SIZEOF_SIGNED_LONG@ - -/* The size of `signed long long', as computed by sizeof. */ -#define SIZEOF_SIGNED_LONG_LONG @SIZEOF_SIGNED_LONG_LONG@ - -/* The size of `unsigned char *', as computed by sizeof. */ -#define SIZEOF_UNSIGNED_CHAR_P @SIZEOF_UNSIGNED_CHAR_P@ - -/* The size of `unsigned int', as computed by sizeof. */ -#define SIZEOF_UNSIGNED_INT @SIZEOF_UNSIGNED_INT@ - -/* The size of `unsigned long', as computed by sizeof. */ -#define SIZEOF_UNSIGNED_LONG @SIZEOF_UNSIGNED_LONG@ - -/* The size of `unsigned long long', as computed by sizeof. */ -#define SIZEOF_UNSIGNED_LONG_LONG @SIZEOF_UNSIGNED_LONG_LONG@ - -/* The size of `unsigned short', as computed by sizeof. */ -#define SIZEOF_UNSIGNED_SHORT @SIZEOF_UNSIGNED_SHORT@ +/* Size of size_t */ +#define SIZEOF_SIZE_T @SIZEOF_SIZE_T@ /* Default size of the strip in bytes (when strip chopping enabled) */ #define STRIP_SIZE_DEFAULT @STRIP_SIZE_DEFAULT@ -/* Signed 32-bit type formatter */ -#define TIFF_INT32_FORMAT "@TIFF_INT32_FORMAT@" - -/* Signed 64-bit type formatter */ -#define TIFF_INT64_FORMAT "@TIFF_INT64_FORMAT@" - -/* Pointer difference type formatter */ -#define TIFF_PTRDIFF_FORMAT "@TIFF_PTRDIFF_FORMAT@" - -/* Unsigned size type formatter */ -#define TIFF_SIZE_FORMAT "@TIFF_SIZE_FORMAT@" - -/* Signed size type formatter */ -#define TIFF_SSIZE_FORMAT "@TIFF_SSIZE_FORMAT@" - -/* Unsigned 32-bit type formatter */ -#define TIFF_UINT32_FORMAT "@TIFF_UINT32_FORMAT@" - -/* Unsigned 64-bit type formatter */ -#define TIFF_UINT64_FORMAT "@TIFF_UINT64_FORMAT@" - -/* Unsigned 8-bit type */ -#define TIFF_UINT8_T @TIFF_UINT8_T@ - -/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */ -#undef TIME_WITH_SYS_TIME - -/* Define to 1 if your <sys/time.h> declares `struct tm'. */ -#cmakedefine TM_IN_SYS_TIME 1 - /* define to use win32 IO system */ #cmakedefine USE_WIN32_FILEIO 1 /* Version number of package */ #define VERSION "@PACKAGE_VERSION@" +/* Support WEBP compression */ +#cmakedefine WEBP_SUPPORT 1 + +/* Support ZSTD compression */ +#cmakedefine ZSTD_SUPPORT 1 + + /* 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 @@ -215,17 +137,19 @@ # endif #endif -/* Number of bits in a file offset, on hosts where this is settable. */ -#define _FILE_OFFSET_BITS @FILE_OFFSET_BITS@ - -/* Define to `__inline__' or `__inline' if that's what the C compiler - calls it, or to nothing if 'inline' is not supported under any name. */ -#ifndef __cplusplus -#define inline @INLINE_KEYWORD@ +#if !defined(__MINGW32__) +# define TIFF_SIZE_FORMAT "zu" +#endif +#if SIZEOF_SIZE_T == 8 +# define TIFF_SSIZE_FORMAT PRId64 +# if defined(__MINGW32__) +# define TIFF_SIZE_FORMAT PRIu64 +# endif +#elif SIZEOF_SIZE_T == 4 +# define TIFF_SSIZE_FORMAT PRId32 +# if defined(__MINGW32__) +# define TIFF_SIZE_FORMAT PRIu32 +# endif +#else +# error "Unsupported size_t size; please submit a bug report" #endif - -/* Define to `long int' if <sys/types.h> does not define. */ -#undef off_t - -/* Define to `unsigned int' if <sys/types.h> does not define. */ -#undef size_t diff --git a/tiff/libtiff/tif_config.h.in b/tiff/libtiff/tif_config.h.in index 30afd7a1..66eef23b 100644 --- a/tiff/libtiff/tif_config.h.in +++ b/tiff/libtiff/tif_config.h.in @@ -1,7 +1,6 @@ -/* libtiff/tif_config.h.in. Generated from configure.ac by autoheader. */ +/* libtiff/tif_config.h.in. Not generated, but originated from autoheader. */ -/* Define if building universal (internal helper macro) */ -#undef AC_APPLE_UNIVERSAL_BUILD +#include "tiffconf.h" /* Support CCITT Group 3 & 4 algorithms */ #undef CCITT_SUPPORT @@ -16,11 +15,6 @@ /* Support C++ stream API (requires C++ compiler) */ #undef CXX_SUPPORT -/* Treat extra sample as alpha (default enabled). The RGBA interface will - treat a fourth sample with no EXTRASAMPLE_ value as being ASSOCALPHA. Many - packages produce RGBA files but don't mark the alpha properly. */ -#undef DEFAULT_EXTRASAMPLE_AS_ALPHA - /* enable deferred strip/tile offset/size loading */ #undef DEFER_STRILE_LOAD @@ -31,9 +25,6 @@ */ #undef HAVE_DECL_OPTARG -/* Define to 1 if you have the <dlfcn.h> header file. */ -#undef HAVE_DLFCN_H - /* Define to 1 if you have the <fcntl.h> header file. */ #undef HAVE_FCNTL_H @@ -55,25 +46,12 @@ /* Define to 1 if you have the <GL/gl.h> header file. */ #undef HAVE_GL_GL_H -/* Define as 0 or 1 according to the floating point format suported by the - machine */ -#undef HAVE_IEEEFP - -/* 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 `jbg_newlen' function. */ #undef HAVE_JBG_NEWLEN -/* Define to 1 if you have the `lfind' function. */ -#undef HAVE_LFIND - -/* Define to 1 if you have the <memory.h> header file. */ -#undef HAVE_MEMORY_H - /* Define to 1 if you have the `mmap' function. */ #undef HAVE_MMAP @@ -83,103 +61,33 @@ /* Define to 1 if you have the <OpenGL/gl.h> header file. */ #undef HAVE_OPENGL_GL_H -/* Define if you have POSIX threads libraries and header files. */ -#undef HAVE_PTHREAD - -/* 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 `snprintf' function. */ #undef HAVE_SNPRINTF -/* Define to 1 if you have the <stdint.h> header file. */ -#undef HAVE_STDINT_H - -/* Define to 1 if you have the <stdlib.h> header file. */ -#undef HAVE_STDLIB_H - -/* Define to 1 if you have the `strcasecmp' function. */ -#undef HAVE_STRCASECMP - /* Define to 1 if you have the <strings.h> header file. */ #undef HAVE_STRINGS_H -/* Define to 1 if you have the <string.h> header file. */ -#undef HAVE_STRING_H - -/* Define to 1 if you have the `strtol' function. */ -#undef HAVE_STRTOL - -/* Define to 1 if you have the `strtoll' function. */ -#undef HAVE_STRTOLL - -/* Define to 1 if you have the `strtoul' function. */ -#undef HAVE_STRTOUL - -/* Define to 1 if you have the `strtoull' function. */ -#undef HAVE_STRTOULL - -/* Define to 1 if you have the <sys/stat.h> header file. */ -#undef HAVE_SYS_STAT_H - /* Define to 1 if you have the <sys/types.h> header file. */ #undef HAVE_SYS_TYPES_H /* Define to 1 if you have the <unistd.h> header file. */ #undef HAVE_UNISTD_H -/* Use nonstandard varargs form for the GLU tesselator callback */ -#undef HAVE_VARARGS_GLU_TESSCB - -/* Define to 1 if you have the <windows.h> header file. */ -#undef HAVE_WINDOWS_H - -/* Native cpu byte order: 1 if big-endian (Motorola) or 0 if little-endian - (Intel) */ -#undef HOST_BIGENDIAN - -/* 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 - /* 8/12 bit libjpeg dual mode enabled */ #undef JPEG_DUAL_MODE_8_12 -/* Support JPEG compression (requires IJG JPEG library) */ -#undef JPEG_SUPPORT - -/* Support libdeflate enhanced compression */ -#undef LIBDEFLATE_SUPPORT +/* Support LERC compression */ +#undef LERC_SUPPORT /* 12bit libjpeg primary include file with path */ #undef LIBJPEG_12_PATH -/* Support LogLuv high dynamic range encoding */ -#undef LOGLUV_SUPPORT - -/* Define to the sub-directory where libtool stores uninstalled libraries. */ -#undef LT_OBJDIR - /* Support LZMA2 compression */ #undef LZMA_SUPPORT -/* Support LZW algorithm */ -#undef LZW_SUPPORT - -/* Support Microsoft Document Imaging format */ -#undef MDI_SUPPORT - -/* Support NeXT 2-bit RLE algorithm */ -#undef NEXT_SUPPORT - -/* Support Old JPEG compresson (read-only) */ -#undef OJPEG_SUPPORT - /* Name of package */ #undef PACKAGE @@ -201,116 +109,12 @@ /* Define to the version of this package. */ #undef PACKAGE_VERSION -/* Support Macintosh PackBits algorithm */ -#undef PACKBITS_SUPPORT - -/* Support Pixar log-format algorithm (requires Zlib) */ -#undef PIXARLOG_SUPPORT - -/* Define to necessary symbol if this constant uses a non-standard name on - your system. */ -#undef PTHREAD_CREATE_JOINABLE - -/* The size of `signed int', as computed by sizeof. */ -#undef SIZEOF_SIGNED_INT - -/* 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 `size_t', as computed by sizeof. */ #undef SIZEOF_SIZE_T -/* The size of `unsigned char *', as computed by sizeof. */ -#undef SIZEOF_UNSIGNED_CHAR_P - -/* The size of `unsigned int', as computed by sizeof. */ -#undef SIZEOF_UNSIGNED_INT - -/* 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 - -/* Support strip chopping (whether or not to convert single-strip uncompressed - images to mutiple strips of specified size to reduce memory usage) */ -#undef STRIPCHOP_DEFAULT - /* Default size of the strip in bytes (when strip chopping enabled) */ #undef STRIP_SIZE_DEFAULT -/* Enable SubIFD tag (330) support */ -#undef SUBIFD_SUPPORT - -/* Support ThunderScan 4-bit RLE algorithm */ -#undef THUNDER_SUPPORT - -/* Signed 16-bit type */ -#undef TIFF_INT16_T - -/* Signed 32-bit type formatter */ -#undef TIFF_INT32_FORMAT - -/* Signed 32-bit type */ -#undef TIFF_INT32_T - -/* Signed 64-bit type formatter */ -#undef TIFF_INT64_FORMAT - -/* Signed 64-bit type */ -#undef TIFF_INT64_T - -/* Signed 8-bit type */ -#undef TIFF_INT8_T - -/* Pointer difference type formatter */ -#undef TIFF_PTRDIFF_FORMAT - -/* Pointer difference type */ -#undef TIFF_PTRDIFF_T - -/* Size type formatter */ -#undef TIFF_SIZE_FORMAT - -/* Unsigned size type */ -#undef TIFF_SIZE_T - -/* Signed size type formatter */ -#undef TIFF_SSIZE_FORMAT - -/* Signed size type */ -#undef TIFF_SSIZE_T - -/* Unsigned 16-bit type */ -#undef TIFF_UINT16_T - -/* Unsigned 32-bit type formatter */ -#undef TIFF_UINT32_FORMAT - -/* Unsigned 32-bit type */ -#undef TIFF_UINT32_T - -/* Unsigned 64-bit type formatter */ -#undef TIFF_UINT64_FORMAT - -/* Unsigned 64-bit type */ -#undef TIFF_UINT64_T - -/* Unsigned 8-bit type */ -#undef TIFF_UINT8_T - -/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */ -#undef TIME_WITH_SYS_TIME - -/* Define to 1 if your <sys/time.h> declares `struct tm'. */ -#undef TM_IN_SYS_TIME - /* define to use win32 IO system */ #undef USE_WIN32_FILEIO @@ -332,12 +136,6 @@ # endif #endif -/* Define to 1 if the X Window System is missing or not being used. */ -#undef X_DISPLAY_MISSING - -/* Support Deflate compression */ -#undef ZIP_SUPPORT - /* Support zstd compression */ #undef ZSTD_SUPPORT @@ -355,17 +153,19 @@ /* Define for large files, on AIX-style hosts. */ #undef _LARGE_FILES -/* Define to empty if `const' does not conform to ANSI C. */ -#undef const - -/* 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 -#undef inline +#if !defined(__MINGW32__) +# define TIFF_SIZE_FORMAT "zu" +#endif +#if SIZEOF_SIZE_T == 8 +# define TIFF_SSIZE_FORMAT PRId64 +# if defined(__MINGW32__) +# define TIFF_SIZE_FORMAT PRIu64 +# endif +#elif SIZEOF_SIZE_T == 4 +# define TIFF_SSIZE_FORMAT PRId32 +# if defined(__MINGW32__) +# define TIFF_SIZE_FORMAT PRIu32 +# endif +#else +# error "Unsupported size_t size; please submit a bug report" #endif - -/* Define to `long int' if <sys/types.h> does not define. */ -#undef off_t - -/* Define to `unsigned int' if <sys/types.h> does not define. */ -#undef size_t diff --git a/tiff/libtiff/tif_config.vc.h b/tiff/libtiff/tif_config.vc.h index 939594f8..5cebfa02 100644 --- a/tiff/libtiff/tif_config.vc.h +++ b/tiff/libtiff/tif_config.vc.h @@ -104,24 +104,11 @@ /* Set the native cpu bit order */ #define HOST_FILLORDER FILLORDER_LSB2MSB -/* - Please see associated settings in "nmake.opt" which configure porting - settings. It should not be necessary to edit the following pre-processor - logic. -*/ -#if defined(_MSC_VER) /* Visual Studio 2015 / VC 14 / MSVC 19.00 finally has snprintf() */ -# if _MSC_VER < 1900 /* Visual C++ 2015 */ -# define snprintf _snprintf -# else -# define HAVE_SNPRINTF 1 -# endif -# define HAVE_STRTOL 1 -# define HAVE_STRTOUL 1 -# if _MSC_VER >= 1900 /* Visual Studio 2015 added strtoll/strtoull */ -# define HAVE_STRTOLL 1 -# define HAVE_STRTOULL 1 -# endif +#if defined(_MSC_VER) && _MSC_VER < 1900 +#define snprintf _snprintf +#else +#define HAVE_SNPRINTF 1 #endif /* Define to 1 if your processor stores words with the most significant byte diff --git a/tiff/libtiff/tif_config.wince.h b/tiff/libtiff/tif_config.wince.h deleted file mode 100644 index e85e2e62..00000000 --- a/tiff/libtiff/tif_config.wince.h +++ /dev/null @@ -1,69 +0,0 @@ -/* - * 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 - -/* 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: - */ diff --git a/tiff/libtiff/tif_dir.c b/tiff/libtiff/tif_dir.c index 347b7115..a6c254fc 100644 --- a/tiff/libtiff/tif_dir.c +++ b/tiff/libtiff/tif_dir.c @@ -54,21 +54,21 @@ setByteArray(void** vpp, void* vp, size_t nmemb, size_t elem_size) _TIFFmemcpy(*vpp, vp, bytes); } } -void _TIFFsetByteArray(void** vpp, void* vp, uint32 n) +void _TIFFsetByteArray(void** vpp, void* vp, uint32_t n) { setByteArray(vpp, vp, n, 1); } void _TIFFsetString(char** cpp, char* cp) { setByteArray((void**) cpp, (void*) cp, strlen(cp)+1, 1); } -static void _TIFFsetNString(char** cpp, char* cp, uint32 n) +static void _TIFFsetNString(char** cpp, char* cp, uint32_t n) { setByteArray((void**) cpp, (void*) cp, n, 1); } -void _TIFFsetShortArray(uint16** wpp, uint16* wp, uint32 n) - { setByteArray((void**) wpp, (void*) wp, n, sizeof (uint16)); } -void _TIFFsetLongArray(uint32** lpp, uint32* lp, uint32 n) - { setByteArray((void**) lpp, (void*) lp, n, sizeof (uint32)); } -static void _TIFFsetLong8Array(uint64** lpp, uint64* lp, uint32 n) - { setByteArray((void**) lpp, (void*) lp, n, sizeof (uint64)); } -void _TIFFsetFloatArray(float** fpp, float* fp, uint32 n) +void _TIFFsetShortArray(uint16_t** wpp, uint16_t* wp, uint32_t n) + { setByteArray((void**) wpp, (void*) wp, n, sizeof (uint16_t)); } +void _TIFFsetLongArray(uint32_t** lpp, uint32_t* lp, uint32_t n) + { setByteArray((void**) lpp, (void*) lp, n, sizeof (uint32_t)); } +static void _TIFFsetLong8Array(uint64_t** lpp, uint64_t* lp, uint32_t n) + { setByteArray((void**) lpp, (void*) lp, n, sizeof (uint64_t)); } +void _TIFFsetFloatArray(float** fpp, float* fp, uint32_t n) { setByteArray((void**) fpp, (void*) fp, n, sizeof (float)); } -void _TIFFsetDoubleArray(double** dpp, double* dp, uint32 n) +void _TIFFsetDoubleArray(double** dpp, double* dp, uint32_t n) { setByteArray((void**) dpp, (void*) dp, n, sizeof (double)); } static void @@ -88,20 +88,20 @@ setDoubleArrayOneValue(double** vpp, double value, size_t nmemb) * Install extra samples information. */ static int -setExtraSamples(TIFF* tif, va_list ap, uint32* v) +setExtraSamples(TIFF* tif, va_list ap, uint32_t* v) { /* XXX: Unassociated alpha data == 999 is a known Corel Draw bug, see below */ #define EXTRASAMPLE_COREL_UNASSALPHA 999 - uint16* va; - uint32 i; + uint16_t* va; + uint32_t i; TIFFDirectory* td = &tif->tif_dir; static const char module[] = "setExtraSamples"; - *v = (uint16) va_arg(ap, uint16_vap); - if ((uint16) *v > td->td_samplesperpixel) + *v = (uint16_t) va_arg(ap, uint16_vap); + if ((uint16_t) *v > td->td_samplesperpixel) return 0; - va = va_arg(ap, uint16*); + va = va_arg(ap, uint16_t*); if (*v > 0 && va == NULL) /* typically missing param */ return 0; for (i = 0; i < *v; i++) { @@ -130,7 +130,7 @@ setExtraSamples(TIFF* tif, va_list ap, uint32* v) td->td_transferfunction[0] = NULL; } - td->td_extrasamples = (uint16) *v; + td->td_extrasamples = (uint16_t) *v; _TIFFsetShortArray(&td->td_sampleinfo, va, td->td_extrasamples); return 1; @@ -141,11 +141,11 @@ setExtraSamples(TIFF* tif, va_list ap, uint32* v) * Confirm we have "samplesperpixel" ink names separated by \0. Returns * zero if the ink names are not as expected. */ -static uint32 -checkInkNamesString(TIFF* tif, uint32 slen, const char* s) +static uint32_t +checkInkNamesString(TIFF* tif, uint32_t slen, const char* s) { TIFFDirectory* td = &tif->tif_dir; - uint16 i = td->td_samplesperpixel; + uint16_t i = td->td_samplesperpixel; if (slen > 0) { const char* ep = s+slen; @@ -156,29 +156,29 @@ checkInkNamesString(TIFF* tif, uint32 slen, const char* s) goto bad; cp++; /* skip \0 */ } - return ((uint32)(cp-s)); + return ((uint32_t)(cp - s)); } bad: TIFFErrorExt(tif->tif_clientdata, "TIFFSetField", - "%s: Invalid InkNames value; expecting %d names, found %d", + "%s: Invalid InkNames value; expecting %"PRIu16" names, found %"PRIu16, tif->tif_name, td->td_samplesperpixel, - td->td_samplesperpixel-i); + (uint16_t)(td->td_samplesperpixel-i)); return (0); } static int -_TIFFVSetField(TIFF* tif, uint32 tag, va_list ap) +_TIFFVSetField(TIFF* tif, uint32_t tag, va_list ap) { static const char module[] = "_TIFFVSetField"; TIFFDirectory* td = &tif->tif_dir; int status = 1; - uint32 v32, i, v; + uint32_t v32, i, v; double dblval; char* s; const TIFFField *fip = TIFFFindField(tif, tag, TIFF_ANY); - uint32 standard_tag = tag; + uint32_t standard_tag = tag; if( fip == NULL ) /* cannot happen since OkToChangeTag() already checks it */ return 0; /* @@ -193,16 +193,16 @@ _TIFFVSetField(TIFF* tif, uint32 tag, va_list ap) switch (standard_tag) { case TIFFTAG_SUBFILETYPE: - td->td_subfiletype = (uint32) va_arg(ap, uint32); + td->td_subfiletype = (uint32_t) va_arg(ap, uint32_t); break; case TIFFTAG_IMAGEWIDTH: - td->td_imagewidth = (uint32) va_arg(ap, uint32); + td->td_imagewidth = (uint32_t) va_arg(ap, uint32_t); break; case TIFFTAG_IMAGELENGTH: - td->td_imagelength = (uint32) va_arg(ap, uint32); + td->td_imagelength = (uint32_t) va_arg(ap, uint32_t); break; case TIFFTAG_BITSPERSAMPLE: - td->td_bitspersample = (uint16) va_arg(ap, uint16_vap); + td->td_bitspersample = (uint16_t) va_arg(ap, uint16_vap); /* * If the data require post-decoding processing to byte-swap * samples, set it up here. Note that since tags are required @@ -226,14 +226,14 @@ _TIFFVSetField(TIFF* tif, uint32 tag, va_list ap) } break; case TIFFTAG_COMPRESSION: - v = (uint16) va_arg(ap, uint16_vap); + v = (uint16_t) va_arg(ap, uint16_vap); /* * If we're changing the compression scheme, the notify the * previous module so that it can cleanup any state it's * setup. */ if (TIFFFieldSet(tif, FIELD_COMPRESSION)) { - if ((uint32)td->td_compression == v) + if ((uint32_t)td->td_compression == v) break; (*tif->tif_cleanup)(tif); tif->tif_flags &= ~TIFF_CODERSETUP; @@ -242,31 +242,31 @@ _TIFFVSetField(TIFF* tif, uint32 tag, va_list ap) * Setup new compression routine state. */ if( (status = TIFFSetCompressionScheme(tif, v)) != 0 ) - td->td_compression = (uint16) v; + td->td_compression = (uint16_t) v; else status = 0; break; case TIFFTAG_PHOTOMETRIC: - td->td_photometric = (uint16) va_arg(ap, uint16_vap); + td->td_photometric = (uint16_t) va_arg(ap, uint16_vap); break; case TIFFTAG_THRESHHOLDING: - td->td_threshholding = (uint16) va_arg(ap, uint16_vap); + td->td_threshholding = (uint16_t) va_arg(ap, uint16_vap); break; case TIFFTAG_FILLORDER: - v = (uint16) va_arg(ap, uint16_vap); + v = (uint16_t) va_arg(ap, uint16_vap); if (v != FILLORDER_LSB2MSB && v != FILLORDER_MSB2LSB) goto badvalue; - td->td_fillorder = (uint16) v; + td->td_fillorder = (uint16_t) v; break; case TIFFTAG_ORIENTATION: - v = (uint16) va_arg(ap, uint16_vap); + v = (uint16_t) va_arg(ap, uint16_vap); if (v < ORIENTATION_TOPLEFT || ORIENTATION_LEFTBOT < v) goto badvalue; else - td->td_orientation = (uint16) v; + td->td_orientation = (uint16_t) v; break; case TIFFTAG_SAMPLESPERPIXEL: - v = (uint16) va_arg(ap, uint16_vap); + v = (uint16_t) va_arg(ap, uint16_vap); if (v == 0) goto badvalue; if( v != td->td_samplesperpixel ) @@ -303,10 +303,10 @@ _TIFFVSetField(TIFF* tif, uint32 tag, va_list ap) td->td_transferfunction[0] = NULL; } } - td->td_samplesperpixel = (uint16) v; + td->td_samplesperpixel = (uint16_t) v; break; case TIFFTAG_ROWSPERSTRIP: - v32 = (uint32) va_arg(ap, uint32); + v32 = (uint32_t) va_arg(ap, uint32_t); if (v32 == 0) goto badvalue32; td->td_rowsperstrip = v32; @@ -316,10 +316,10 @@ _TIFFVSetField(TIFF* tif, uint32 tag, va_list ap) } break; case TIFFTAG_MINSAMPLEVALUE: - td->td_minsamplevalue = (uint16) va_arg(ap, uint16_vap); + td->td_minsamplevalue = (uint16_t) va_arg(ap, uint16_vap); break; case TIFFTAG_MAXSAMPLEVALUE: - td->td_maxsamplevalue = (uint16) va_arg(ap, uint16_vap); + td->td_maxsamplevalue = (uint16_t) va_arg(ap, uint16_vap); break; case TIFFTAG_SMINSAMPLEVALUE: if (tif->tif_flags & TIFF_PERSAMPLE) @@ -346,10 +346,10 @@ _TIFFVSetField(TIFF* tif, uint32 tag, va_list ap) td->td_yresolution = _TIFFClampDoubleToFloat( dblval ); break; case TIFFTAG_PLANARCONFIG: - v = (uint16) va_arg(ap, uint16_vap); + v = (uint16_t) va_arg(ap, uint16_vap); if (v != PLANARCONFIG_CONTIG && v != PLANARCONFIG_SEPARATE) goto badvalue; - td->td_planarconfig = (uint16) v; + td->td_planarconfig = (uint16_t) v; break; case TIFFTAG_XPOSITION: td->td_xposition = _TIFFClampDoubleToFloat( va_arg(ap, double) ); @@ -358,66 +358,66 @@ _TIFFVSetField(TIFF* tif, uint32 tag, va_list ap) td->td_yposition = _TIFFClampDoubleToFloat( va_arg(ap, double) ); break; case TIFFTAG_RESOLUTIONUNIT: - v = (uint16) va_arg(ap, uint16_vap); + v = (uint16_t) va_arg(ap, uint16_vap); if (v < RESUNIT_NONE || RESUNIT_CENTIMETER < v) goto badvalue; - td->td_resolutionunit = (uint16) v; + td->td_resolutionunit = (uint16_t) v; break; case TIFFTAG_PAGENUMBER: - td->td_pagenumber[0] = (uint16) va_arg(ap, uint16_vap); - td->td_pagenumber[1] = (uint16) va_arg(ap, uint16_vap); + td->td_pagenumber[0] = (uint16_t) va_arg(ap, uint16_vap); + td->td_pagenumber[1] = (uint16_t) va_arg(ap, uint16_vap); break; case TIFFTAG_HALFTONEHINTS: - td->td_halftonehints[0] = (uint16) va_arg(ap, uint16_vap); - td->td_halftonehints[1] = (uint16) va_arg(ap, uint16_vap); + td->td_halftonehints[0] = (uint16_t) va_arg(ap, uint16_vap); + td->td_halftonehints[1] = (uint16_t) va_arg(ap, uint16_vap); break; case TIFFTAG_COLORMAP: - v32 = (uint32)(1L<<td->td_bitspersample); - _TIFFsetShortArray(&td->td_colormap[0], va_arg(ap, uint16*), v32); - _TIFFsetShortArray(&td->td_colormap[1], va_arg(ap, uint16*), v32); - _TIFFsetShortArray(&td->td_colormap[2], va_arg(ap, uint16*), v32); + v32 = (uint32_t)(1L << td->td_bitspersample); + _TIFFsetShortArray(&td->td_colormap[0], va_arg(ap, uint16_t*), v32); + _TIFFsetShortArray(&td->td_colormap[1], va_arg(ap, uint16_t*), v32); + _TIFFsetShortArray(&td->td_colormap[2], va_arg(ap, uint16_t*), v32); break; case TIFFTAG_EXTRASAMPLES: if (!setExtraSamples(tif, ap, &v)) goto badvalue; break; case TIFFTAG_MATTEING: - td->td_extrasamples = (((uint16) va_arg(ap, uint16_vap)) != 0); + td->td_extrasamples = (((uint16_t) va_arg(ap, uint16_vap)) != 0); if (td->td_extrasamples) { - uint16 sv = EXTRASAMPLE_ASSOCALPHA; + uint16_t sv = EXTRASAMPLE_ASSOCALPHA; _TIFFsetShortArray(&td->td_sampleinfo, &sv, 1); } break; case TIFFTAG_TILEWIDTH: - v32 = (uint32) va_arg(ap, uint32); + v32 = (uint32_t) va_arg(ap, uint32_t); if (v32 % 16) { if (tif->tif_mode != O_RDONLY) goto badvalue32; TIFFWarningExt(tif->tif_clientdata, tif->tif_name, - "Nonstandard tile width %u, convert file", v32); + "Nonstandard tile width %"PRIu32", convert file", v32); } td->td_tilewidth = v32; tif->tif_flags |= TIFF_ISTILED; break; case TIFFTAG_TILELENGTH: - v32 = (uint32) va_arg(ap, uint32); + v32 = (uint32_t) va_arg(ap, uint32_t); if (v32 % 16) { if (tif->tif_mode != O_RDONLY) goto badvalue32; TIFFWarningExt(tif->tif_clientdata, tif->tif_name, - "Nonstandard tile length %u, convert file", v32); + "Nonstandard tile length %"PRIu32", convert file", v32); } td->td_tilelength = v32; tif->tif_flags |= TIFF_ISTILED; break; case TIFFTAG_TILEDEPTH: - v32 = (uint32) va_arg(ap, uint32); + v32 = (uint32_t) va_arg(ap, uint32_t); if (v32 == 0) goto badvalue32; td->td_tiledepth = v32; break; case TIFFTAG_DATATYPE: - v = (uint16) va_arg(ap, uint16_vap); + v = (uint16_t) va_arg(ap, uint16_vap); switch (v) { case DATATYPE_VOID: v = SAMPLEFORMAT_VOID; break; case DATATYPE_INT: v = SAMPLEFORMAT_INT; break; @@ -425,13 +425,13 @@ _TIFFVSetField(TIFF* tif, uint32 tag, va_list ap) case DATATYPE_IEEEFP: v = SAMPLEFORMAT_IEEEFP;break; default: goto badvalue; } - td->td_sampleformat = (uint16) v; + td->td_sampleformat = (uint16_t) v; break; case TIFFTAG_SAMPLEFORMAT: - v = (uint16) va_arg(ap, uint16_vap); + v = (uint16_t) va_arg(ap, uint16_vap); if (v < SAMPLEFORMAT_UINT || SAMPLEFORMAT_COMPLEXIEEEFP < v) goto badvalue; - td->td_sampleformat = (uint16) v; + td->td_sampleformat = (uint16_t) v; /* Try to fix up the SWAB function for complex data. */ if( td->td_sampleformat == SAMPLEFORMAT_COMPLEXINT @@ -445,13 +445,13 @@ _TIFFVSetField(TIFF* tif, uint32 tag, va_list ap) tif->tif_postdecode = _TIFFSwab32BitData; break; case TIFFTAG_IMAGEDEPTH: - td->td_imagedepth = (uint32) va_arg(ap, uint32); + td->td_imagedepth = (uint32_t) va_arg(ap, uint32_t); break; case TIFFTAG_SUBIFD: if ((tif->tif_flags & TIFF_INSUBIFD) == 0) { - td->td_nsubifd = (uint16) va_arg(ap, uint16_vap); - _TIFFsetLong8Array(&td->td_subifd, (uint64*) va_arg(ap, uint64*), - (uint32) td->td_nsubifd); + td->td_nsubifd = (uint16_t) va_arg(ap, uint16_vap); + _TIFFsetLong8Array(&td->td_subifd, (uint64_t*) va_arg(ap, uint64_t*), + (uint32_t) td->td_nsubifd); } else { TIFFErrorExt(tif->tif_clientdata, module, "%s: Sorry, cannot nest SubIFDs", @@ -460,24 +460,24 @@ _TIFFVSetField(TIFF* tif, uint32 tag, va_list ap) } break; case TIFFTAG_YCBCRPOSITIONING: - td->td_ycbcrpositioning = (uint16) va_arg(ap, uint16_vap); + td->td_ycbcrpositioning = (uint16_t) va_arg(ap, uint16_vap); break; case TIFFTAG_YCBCRSUBSAMPLING: - td->td_ycbcrsubsampling[0] = (uint16) va_arg(ap, uint16_vap); - td->td_ycbcrsubsampling[1] = (uint16) va_arg(ap, uint16_vap); + td->td_ycbcrsubsampling[0] = (uint16_t) va_arg(ap, uint16_vap); + td->td_ycbcrsubsampling[1] = (uint16_t) va_arg(ap, uint16_vap); break; case TIFFTAG_TRANSFERFUNCTION: v = (td->td_samplesperpixel - td->td_extrasamples) > 1 ? 3 : 1; for (i = 0; i < v; i++) _TIFFsetShortArray(&td->td_transferfunction[i], - va_arg(ap, uint16*), 1U<<td->td_bitspersample); + va_arg(ap, uint16_t*), 1U << 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 = (uint16) va_arg(ap, uint16_vap); + v = (uint16_t) va_arg(ap, uint16_vap); s = va_arg(ap, char*); v = checkInkNamesString(tif, v, s); status = v > 0; @@ -487,7 +487,7 @@ _TIFFVSetField(TIFF* tif, uint32 tag, va_list ap) } break; case TIFFTAG_PERSAMPLE: - v = (uint16) va_arg(ap, uint16_vap); + v = (uint16_t) va_arg(ap, uint16_vap); if( v == PERSAMPLE_MULTI ) tif->tif_flags |= TIFF_PERSAMPLE; else @@ -575,18 +575,18 @@ _TIFFVSetField(TIFF* tif, uint32 tag, va_list ap) if (fip->field_type == TIFF_ASCII) { - uint32 ma; + uint32_t ma; char* mb; if (fip->field_passcount) { assert(fip->field_writecount==TIFF_VARIABLE2); - ma=(uint32)va_arg(ap,uint32); + ma=(uint32_t)va_arg(ap, uint32_t); mb=(char*)va_arg(ap,char*); } else { mb=(char*)va_arg(ap,char*); - ma=(uint32)(strlen(mb)+1); + ma=(uint32_t)(strlen(mb) + 1); } tv->count=ma; setByteArray(&tv->value,mb,ma,1); @@ -595,7 +595,7 @@ _TIFFVSetField(TIFF* tif, uint32 tag, va_list ap) { if (fip->field_passcount) { if (fip->field_writecount == TIFF_VARIABLE2) - tv->count = (uint32) va_arg(ap, uint32); + tv->count = (uint32_t) va_arg(ap, uint32_t); else tv->count = (int) va_arg(ap, int); } else if (fip->field_writecount == TIFF_VARIABLE @@ -632,9 +632,9 @@ _TIFFVSetField(TIFF* tif, uint32 tag, va_list ap) handled this way ... likely best if we move it into the directory structure with an explicit field in libtiff 4.1 and assign it a FIELD_ value */ - uint16 v2[2]; - v2[0] = (uint16)va_arg(ap, int); - v2[1] = (uint16)va_arg(ap, int); + uint16_t v2[2]; + v2[0] = (uint16_t)va_arg(ap, int); + v2[1] = (uint16_t)va_arg(ap, int); _TIFFmemcpy(tv->value, &v2, 4); } @@ -654,51 +654,51 @@ _TIFFVSetField(TIFF* tif, uint32 tag, va_list ap) case TIFF_BYTE: case TIFF_UNDEFINED: { - uint8 v2 = (uint8)va_arg(ap, int); + uint8_t v2 = (uint8_t)va_arg(ap, int); _TIFFmemcpy(val, &v2, tv_size); } break; case TIFF_SBYTE: { - int8 v2 = (int8)va_arg(ap, int); + int8_t v2 = (int8_t)va_arg(ap, int); _TIFFmemcpy(val, &v2, tv_size); } break; case TIFF_SHORT: { - uint16 v2 = (uint16)va_arg(ap, int); + uint16_t v2 = (uint16_t)va_arg(ap, int); _TIFFmemcpy(val, &v2, tv_size); } break; case TIFF_SSHORT: { - int16 v2 = (int16)va_arg(ap, int); + int16_t v2 = (int16_t)va_arg(ap, int); _TIFFmemcpy(val, &v2, tv_size); } break; case TIFF_LONG: case TIFF_IFD: { - uint32 v2 = va_arg(ap, uint32); + uint32_t v2 = va_arg(ap, uint32_t); _TIFFmemcpy(val, &v2, tv_size); } break; case TIFF_SLONG: { - int32 v2 = va_arg(ap, int32); + int32_t v2 = va_arg(ap, int32_t); _TIFFmemcpy(val, &v2, tv_size); } break; case TIFF_LONG8: case TIFF_IFD8: { - uint64 v2 = va_arg(ap, uint64); + uint64_t v2 = va_arg(ap, uint64_t); _TIFFmemcpy(val, &v2, tv_size); } break; case TIFF_SLONG8: { - int64 v2 = va_arg(ap, int64); + int64_t v2 = va_arg(ap, int64_t); _TIFFmemcpy(val, &v2, tv_size); } break; @@ -755,7 +755,7 @@ badvalue: { const TIFFField* fip2=TIFFFieldWithTag(tif,tag); TIFFErrorExt(tif->tif_clientdata, module, - "%s: Bad value %u for \"%s\" tag", + "%s: Bad value %"PRIu32" for \"%s\" tag", tif->tif_name, v, fip2 ? fip2->field_name : "Unknown"); va_end(ap); @@ -765,7 +765,7 @@ badvalue32: { const TIFFField* fip2=TIFFFieldWithTag(tif,tag); TIFFErrorExt(tif->tif_clientdata, module, - "%s: Bad value %u for \"%s\" tag", + "%s: Bad value %"PRIu32" for \"%s\" tag", tif->tif_name, v32, fip2 ? fip2->field_name : "Unknown"); va_end(ap); @@ -793,11 +793,11 @@ badvaluedouble: * on the format of the data that is written. */ static int -OkToChangeTag(TIFF* tif, uint32 tag) +OkToChangeTag(TIFF* tif, uint32_t tag) { const TIFFField* fip = TIFFFindField(tif, tag, TIFF_ANY); if (!fip) { /* unknown tag */ - TIFFErrorExt(tif->tif_clientdata, "TIFFSetField", "%s: Unknown %stag %u", + TIFFErrorExt(tif->tif_clientdata, "TIFFSetField", "%s: Unknown %stag %"PRIu32, tif->tif_name, isPseudoTag(tag) ? "pseudo-" : "", tag); return (0); } @@ -825,7 +825,7 @@ OkToChangeTag(TIFF* tif, uint32 tag) * updated. */ int -TIFFSetField(TIFF* tif, uint32 tag, ...) +TIFFSetField(TIFF* tif, uint32_t tag, ...) { va_list ap; int status; @@ -840,7 +840,7 @@ TIFFSetField(TIFF* tif, uint32 tag, ...) * Clear the contents of the field in the internal structure. */ int -TIFFUnsetField(TIFF* tif, uint32 tag) +TIFFUnsetField(TIFF* tif, uint32_t tag) { const TIFFField *fip = TIFFFieldWithTag(tif, tag); TIFFDirectory* td = &tif->tif_dir; @@ -884,18 +884,18 @@ TIFFUnsetField(TIFF* tif, uint32 tag) * top of the library. */ int -TIFFVSetField(TIFF* tif, uint32 tag, va_list ap) +TIFFVSetField(TIFF* tif, uint32_t tag, va_list ap) { return OkToChangeTag(tif, tag) ? (*tif->tif_tagmethods.vsetfield)(tif, tag, ap) : 0; } static int -_TIFFVGetField(TIFF* tif, uint32 tag, va_list ap) +_TIFFVGetField(TIFF* tif, uint32_t tag, va_list ap) { TIFFDirectory* td = &tif->tif_dir; int ret_val = 1; - uint32 standard_tag = tag; + uint32_t standard_tag = tag; const TIFFField* fip = TIFFFindField(tif, tag, TIFF_ANY); if( fip == NULL ) /* cannot happen since TIFFGetField() already checks it */ return 0; @@ -914,13 +914,13 @@ _TIFFVGetField(TIFF* tif, uint32 tag, va_list ap) { int i; for (i = 0; i < td->td_customValueCount; i++) { - uint16 val; + uint16_t val; TIFFTagValue *tv = td->td_customValues + i; if (tv->info->field_tag != standard_tag) continue; if( tv->value == NULL ) return 0; - val = *(uint16 *)tv->value; + val = *(uint16_t *)tv->value; /* Truncate to SamplesPerPixel, since the */ /* setting code for INKNAMES assume that there are SamplesPerPixel */ /* inknames. */ @@ -928,11 +928,11 @@ _TIFFVGetField(TIFF* tif, uint32 tag, va_list ap) if( val > td->td_samplesperpixel ) { TIFFWarningExt(tif->tif_clientdata,"_TIFFVGetField", - "Truncating NumberOfInks from %u to %u", + "Truncating NumberOfInks from %u to %"PRIu16, val, td->td_samplesperpixel); val = td->td_samplesperpixel; } - *va_arg(ap, uint16*) = val; + *va_arg(ap, uint16_t*) = val; return 1; } return 0; @@ -940,43 +940,43 @@ _TIFFVGetField(TIFF* tif, uint32 tag, va_list ap) switch (standard_tag) { case TIFFTAG_SUBFILETYPE: - *va_arg(ap, uint32*) = td->td_subfiletype; + *va_arg(ap, uint32_t*) = td->td_subfiletype; break; case TIFFTAG_IMAGEWIDTH: - *va_arg(ap, uint32*) = td->td_imagewidth; + *va_arg(ap, uint32_t*) = td->td_imagewidth; break; case TIFFTAG_IMAGELENGTH: - *va_arg(ap, uint32*) = td->td_imagelength; + *va_arg(ap, uint32_t*) = td->td_imagelength; break; case TIFFTAG_BITSPERSAMPLE: - *va_arg(ap, uint16*) = td->td_bitspersample; + *va_arg(ap, uint16_t*) = td->td_bitspersample; break; case TIFFTAG_COMPRESSION: - *va_arg(ap, uint16*) = td->td_compression; + *va_arg(ap, uint16_t*) = td->td_compression; break; case TIFFTAG_PHOTOMETRIC: - *va_arg(ap, uint16*) = td->td_photometric; + *va_arg(ap, uint16_t*) = td->td_photometric; break; case TIFFTAG_THRESHHOLDING: - *va_arg(ap, uint16*) = td->td_threshholding; + *va_arg(ap, uint16_t*) = td->td_threshholding; break; case TIFFTAG_FILLORDER: - *va_arg(ap, uint16*) = td->td_fillorder; + *va_arg(ap, uint16_t*) = td->td_fillorder; break; case TIFFTAG_ORIENTATION: - *va_arg(ap, uint16*) = td->td_orientation; + *va_arg(ap, uint16_t*) = td->td_orientation; break; case TIFFTAG_SAMPLESPERPIXEL: - *va_arg(ap, uint16*) = td->td_samplesperpixel; + *va_arg(ap, uint16_t*) = td->td_samplesperpixel; break; case TIFFTAG_ROWSPERSTRIP: - *va_arg(ap, uint32*) = td->td_rowsperstrip; + *va_arg(ap, uint32_t*) = td->td_rowsperstrip; break; case TIFFTAG_MINSAMPLEVALUE: - *va_arg(ap, uint16*) = td->td_minsamplevalue; + *va_arg(ap, uint16_t*) = td->td_minsamplevalue; break; case TIFFTAG_MAXSAMPLEVALUE: - *va_arg(ap, uint16*) = td->td_maxsamplevalue; + *va_arg(ap, uint16_t*) = td->td_maxsamplevalue; break; case TIFFTAG_SMINSAMPLEVALUE: if (tif->tif_flags & TIFF_PERSAMPLE) @@ -984,7 +984,7 @@ _TIFFVGetField(TIFF* tif, uint32 tag, va_list ap) else { /* libtiff historically treats this as a single value. */ - uint16 i; + uint16_t i; double v = td->td_sminsamplevalue[0]; for (i=1; i < td->td_samplesperpixel; ++i) if( td->td_sminsamplevalue[i] < v ) @@ -998,7 +998,7 @@ _TIFFVGetField(TIFF* tif, uint32 tag, va_list ap) else { /* libtiff historically treats this as a single value. */ - uint16 i; + uint16_t i; double v = td->td_smaxsamplevalue[0]; for (i=1; i < td->td_samplesperpixel; ++i) if( td->td_smaxsamplevalue[i] > v ) @@ -1013,7 +1013,7 @@ _TIFFVGetField(TIFF* tif, uint32 tag, va_list ap) *va_arg(ap, float*) = td->td_yresolution; break; case TIFFTAG_PLANARCONFIG: - *va_arg(ap, uint16*) = td->td_planarconfig; + *va_arg(ap, uint16_t*) = td->td_planarconfig; break; case TIFFTAG_XPOSITION: *va_arg(ap, float*) = td->td_xposition; @@ -1022,90 +1022,90 @@ _TIFFVGetField(TIFF* tif, uint32 tag, va_list ap) *va_arg(ap, float*) = td->td_yposition; break; case TIFFTAG_RESOLUTIONUNIT: - *va_arg(ap, uint16*) = td->td_resolutionunit; + *va_arg(ap, uint16_t*) = td->td_resolutionunit; break; case TIFFTAG_PAGENUMBER: - *va_arg(ap, uint16*) = td->td_pagenumber[0]; - *va_arg(ap, uint16*) = td->td_pagenumber[1]; + *va_arg(ap, uint16_t*) = td->td_pagenumber[0]; + *va_arg(ap, uint16_t*) = td->td_pagenumber[1]; break; case TIFFTAG_HALFTONEHINTS: - *va_arg(ap, uint16*) = td->td_halftonehints[0]; - *va_arg(ap, uint16*) = td->td_halftonehints[1]; + *va_arg(ap, uint16_t*) = td->td_halftonehints[0]; + *va_arg(ap, uint16_t*) = td->td_halftonehints[1]; break; case TIFFTAG_COLORMAP: - *va_arg(ap, const uint16**) = td->td_colormap[0]; - *va_arg(ap, const uint16**) = td->td_colormap[1]; - *va_arg(ap, const uint16**) = td->td_colormap[2]; + *va_arg(ap, const uint16_t**) = td->td_colormap[0]; + *va_arg(ap, const uint16_t**) = td->td_colormap[1]; + *va_arg(ap, const uint16_t**) = td->td_colormap[2]; break; case TIFFTAG_STRIPOFFSETS: case TIFFTAG_TILEOFFSETS: _TIFFFillStriles( tif ); - *va_arg(ap, const uint64**) = td->td_stripoffset_p; + *va_arg(ap, const uint64_t**) = td->td_stripoffset_p; break; case TIFFTAG_STRIPBYTECOUNTS: case TIFFTAG_TILEBYTECOUNTS: _TIFFFillStriles( tif ); - *va_arg(ap, const uint64**) = td->td_stripbytecount_p; + *va_arg(ap, const uint64_t**) = td->td_stripbytecount_p; break; case TIFFTAG_MATTEING: - *va_arg(ap, uint16*) = + *va_arg(ap, uint16_t*) = (td->td_extrasamples == 1 && td->td_sampleinfo[0] == EXTRASAMPLE_ASSOCALPHA); break; case TIFFTAG_EXTRASAMPLES: - *va_arg(ap, uint16*) = td->td_extrasamples; - *va_arg(ap, const uint16**) = td->td_sampleinfo; + *va_arg(ap, uint16_t*) = td->td_extrasamples; + *va_arg(ap, const uint16_t**) = td->td_sampleinfo; break; case TIFFTAG_TILEWIDTH: - *va_arg(ap, uint32*) = td->td_tilewidth; + *va_arg(ap, uint32_t*) = td->td_tilewidth; break; case TIFFTAG_TILELENGTH: - *va_arg(ap, uint32*) = td->td_tilelength; + *va_arg(ap, uint32_t*) = td->td_tilelength; break; case TIFFTAG_TILEDEPTH: - *va_arg(ap, uint32*) = td->td_tiledepth; + *va_arg(ap, uint32_t*) = td->td_tiledepth; break; case TIFFTAG_DATATYPE: switch (td->td_sampleformat) { case SAMPLEFORMAT_UINT: - *va_arg(ap, uint16*) = DATATYPE_UINT; + *va_arg(ap, uint16_t*) = DATATYPE_UINT; break; case SAMPLEFORMAT_INT: - *va_arg(ap, uint16*) = DATATYPE_INT; + *va_arg(ap, uint16_t*) = DATATYPE_INT; break; case SAMPLEFORMAT_IEEEFP: - *va_arg(ap, uint16*) = DATATYPE_IEEEFP; + *va_arg(ap, uint16_t*) = DATATYPE_IEEEFP; break; case SAMPLEFORMAT_VOID: - *va_arg(ap, uint16*) = DATATYPE_VOID; + *va_arg(ap, uint16_t*) = DATATYPE_VOID; break; } break; case TIFFTAG_SAMPLEFORMAT: - *va_arg(ap, uint16*) = td->td_sampleformat; + *va_arg(ap, uint16_t*) = td->td_sampleformat; break; case TIFFTAG_IMAGEDEPTH: - *va_arg(ap, uint32*) = td->td_imagedepth; + *va_arg(ap, uint32_t*) = td->td_imagedepth; break; case TIFFTAG_SUBIFD: - *va_arg(ap, uint16*) = td->td_nsubifd; - *va_arg(ap, const uint64**) = td->td_subifd; + *va_arg(ap, uint16_t*) = td->td_nsubifd; + *va_arg(ap, const uint64_t**) = td->td_subifd; break; case TIFFTAG_YCBCRPOSITIONING: - *va_arg(ap, uint16*) = td->td_ycbcrpositioning; + *va_arg(ap, uint16_t*) = td->td_ycbcrpositioning; break; case TIFFTAG_YCBCRSUBSAMPLING: - *va_arg(ap, uint16*) = td->td_ycbcrsubsampling[0]; - *va_arg(ap, uint16*) = td->td_ycbcrsubsampling[1]; + *va_arg(ap, uint16_t*) = td->td_ycbcrsubsampling[0]; + *va_arg(ap, uint16_t*) = td->td_ycbcrsubsampling[1]; break; case TIFFTAG_TRANSFERFUNCTION: - *va_arg(ap, const uint16**) = td->td_transferfunction[0]; + *va_arg(ap, const uint16_t**) = td->td_transferfunction[0]; if (td->td_samplesperpixel - td->td_extrasamples > 1) { - *va_arg(ap, const uint16**) = td->td_transferfunction[1]; - *va_arg(ap, const uint16**) = td->td_transferfunction[2]; + *va_arg(ap, const uint16_t**) = td->td_transferfunction[1]; + *va_arg(ap, const uint16_t**) = td->td_transferfunction[2]; } else { - *va_arg(ap, const uint16**) = NULL; - *va_arg(ap, const uint16**) = NULL; + *va_arg(ap, const uint16_t**) = NULL; + *va_arg(ap, const uint16_t**) = NULL; } break; case TIFFTAG_REFERENCEBLACKWHITE: @@ -1151,9 +1151,9 @@ _TIFFVGetField(TIFF* tif, uint32 tag, va_list ap) if (fip->field_passcount) { if (fip->field_readcount == TIFF_VARIABLE2) - *va_arg(ap, uint32*) = (uint32)tv->count; + *va_arg(ap, uint32_t*) = (uint32_t)tv->count; else /* Assume TIFF_VARIABLE */ - *va_arg(ap, uint16*) = (uint16)tv->count; + *va_arg(ap, uint16_t*) = (uint16_t)tv->count; *va_arg(ap, const void **) = tv->value; ret_val = 1; } else if (fip->field_tag == TIFFTAG_DOTRANGE @@ -1162,8 +1162,8 @@ _TIFFVGetField(TIFF* tif, uint32 tag, va_list ap) handled this way ... likely best if we move it into the directory structure with an explicit field in libtiff 4.1 and assign it a FIELD_ value */ - *va_arg(ap, uint16*) = ((uint16 *)tv->value)[0]; - *va_arg(ap, uint16*) = ((uint16 *)tv->value)[1]; + *va_arg(ap, uint16_t*) = ((uint16_t *)tv->value)[0]; + *va_arg(ap, uint16_t*) = ((uint16_t *)tv->value)[1]; ret_val = 1; } else { if (fip->field_type == TIFF_ASCII @@ -1179,45 +1179,45 @@ _TIFFVGetField(TIFF* tif, uint32 tag, va_list ap) switch (fip->field_type) { case TIFF_BYTE: case TIFF_UNDEFINED: - *va_arg(ap, uint8*) = - *(uint8 *)val; + *va_arg(ap, uint8_t*) = + *(uint8_t *)val; ret_val = 1; break; case TIFF_SBYTE: - *va_arg(ap, int8*) = - *(int8 *)val; + *va_arg(ap, int8_t*) = + *(int8_t *)val; ret_val = 1; break; case TIFF_SHORT: - *va_arg(ap, uint16*) = - *(uint16 *)val; + *va_arg(ap, uint16_t*) = + *(uint16_t *)val; ret_val = 1; break; case TIFF_SSHORT: - *va_arg(ap, int16*) = - *(int16 *)val; + *va_arg(ap, int16_t*) = + *(int16_t *)val; ret_val = 1; break; case TIFF_LONG: case TIFF_IFD: - *va_arg(ap, uint32*) = - *(uint32 *)val; + *va_arg(ap, uint32_t*) = + *(uint32_t *)val; ret_val = 1; break; case TIFF_SLONG: - *va_arg(ap, int32*) = - *(int32 *)val; + *va_arg(ap, int32_t*) = + *(int32_t *)val; ret_val = 1; break; case TIFF_LONG8: case TIFF_IFD8: - *va_arg(ap, uint64*) = - *(uint64 *)val; + *va_arg(ap, uint64_t*) = + *(uint64_t *)val; ret_val = 1; break; case TIFF_SLONG8: - *va_arg(ap, int64*) = - *(int64 *)val; + *va_arg(ap, int64_t*) = + *(int64_t *)val; ret_val = 1; break; case TIFF_RATIONAL: @@ -1267,7 +1267,7 @@ _TIFFVGetField(TIFF* tif, uint32 tag, va_list ap) * internal directory structure. */ int -TIFFGetField(TIFF* tif, uint32 tag, ...) +TIFFGetField(TIFF* tif, uint32_t tag, ...) { int status; va_list ap; @@ -1285,7 +1285,7 @@ TIFFGetField(TIFF* tif, uint32 tag, ...) * top of the library. */ int -TIFFVGetField(TIFF* tif, uint32 tag, va_list ap) +TIFFVGetField(TIFF* tif, uint32_t tag, va_list ap) { const TIFFField* fip = TIFFFindField(tif, tag, TIFF_ANY); return (fip && (isPseudoTag(tag) || TIFFFieldSet(tif, fip->field_bit)) ? @@ -1368,8 +1368,8 @@ TIFFCreateDirectory(TIFF* tif) tif->tif_diroff = 0; tif->tif_nextdiroff = 0; tif->tif_curoff = 0; - tif->tif_row = (uint32) -1; - tif->tif_curstrip = (uint32) -1; + tif->tif_row = (uint32_t) -1; + tif->tif_curstrip = (uint32_t) -1; return 0; } @@ -1381,7 +1381,7 @@ TIFFCreateCustomDirectory(TIFF* tif, const TIFFFieldArray* infoarray) /* * Reset the field definitions to match the application provided list. - * Hopefully TIFFDefaultDirectory() won't have done anything irreversable + * Hopefully TIFFDefaultDirectory() won't have done anything irreversible * based on it's assumption this is an image directory. */ _TIFFSetupFields(tif, infoarray); @@ -1389,8 +1389,8 @@ TIFFCreateCustomDirectory(TIFF* tif, const TIFFFieldArray* infoarray) tif->tif_diroff = 0; tif->tif_nextdiroff = 0; tif->tif_curoff = 0; - tif->tif_row = (uint32) -1; - tif->tif_curstrip = (uint32) -1; + tif->tif_row = (uint32_t) -1; + tif->tif_curstrip = (uint32_t) -1; return 0; } @@ -1432,7 +1432,7 @@ TIFFDefaultDirectory(TIFF* tif) td->td_threshholding = THRESHHOLD_BILEVEL; td->td_orientation = ORIENTATION_TOPLEFT; td->td_samplesperpixel = 1; - td->td_rowsperstrip = (uint32) -1; + td->td_rowsperstrip = (uint32_t) -1; td->td_tilewidth = 0; td->td_tilelength = 0; td->td_tiledepth = 1; @@ -1456,7 +1456,7 @@ TIFFDefaultDirectory(TIFF* tif) * but do some prior cleanup first. (http://trac.osgeo.org/gdal/ticket/5054) */ if (tif->tif_nfieldscompat > 0) { - uint32 i; + uint32_t i; for (i = 0; i < tif->tif_nfieldscompat; i++) { if (tif->tif_fieldscompat[i].allocated_size) @@ -1490,38 +1490,38 @@ TIFFDefaultDirectory(TIFF* tif) } static int -TIFFAdvanceDirectory(TIFF* tif, uint64* nextdir, uint64* off) +TIFFAdvanceDirectory(TIFF* tif, uint64_t* nextdir, uint64_t* off) { static const char module[] = "TIFFAdvanceDirectory"; if (isMapped(tif)) { - uint64 poff=*nextdir; + uint64_t poff=*nextdir; if (!(tif->tif_flags&TIFF_BIGTIFF)) { tmsize_t poffa,poffb,poffc,poffd; - uint16 dircount; - uint32 nextdir32; + uint16_t dircount; + uint32_t nextdir32; poffa=(tmsize_t)poff; - poffb=poffa+sizeof(uint16); - if (((uint64)poffa!=poff)||(poffb<poffa)||(poffb<(tmsize_t)sizeof(uint16))||(poffb>tif->tif_size)) + poffb=poffa+sizeof(uint16_t); + if (((uint64_t)poffa != poff) || (poffb < poffa) || (poffb < (tmsize_t)sizeof(uint16_t)) || (poffb > tif->tif_size)) { TIFFErrorExt(tif->tif_clientdata,module,"Error fetching directory count"); *nextdir=0; return(0); } - _TIFFmemcpy(&dircount,tif->tif_base+poffa,sizeof(uint16)); + _TIFFmemcpy(&dircount,tif->tif_base+poffa,sizeof(uint16_t)); if (tif->tif_flags&TIFF_SWAB) TIFFSwabShort(&dircount); poffc=poffb+dircount*12; - poffd=poffc+sizeof(uint32); - if ((poffc<poffb)||(poffc<dircount*12)||(poffd<poffc)||(poffd<(tmsize_t)sizeof(uint32))||(poffd>tif->tif_size)) + poffd=poffc+sizeof(uint32_t); + if ((poffc<poffb) || (poffc<dircount*12) || (poffd<poffc) || (poffd<(tmsize_t)sizeof(uint32_t)) || (poffd > tif->tif_size)) { TIFFErrorExt(tif->tif_clientdata,module,"Error fetching directory link"); return(0); } if (off!=NULL) - *off=(uint64)poffc; - _TIFFmemcpy(&nextdir32,tif->tif_base+poffc,sizeof(uint32)); + *off=(uint64_t)poffc; + _TIFFmemcpy(&nextdir32,tif->tif_base+poffc,sizeof(uint32_t)); if (tif->tif_flags&TIFF_SWAB) TIFFSwabLong(&nextdir32); *nextdir=nextdir32; @@ -1529,16 +1529,16 @@ TIFFAdvanceDirectory(TIFF* tif, uint64* nextdir, uint64* off) else { tmsize_t poffa,poffb,poffc,poffd; - uint64 dircount64; - uint16 dircount16; + uint64_t dircount64; + uint16_t dircount16; poffa=(tmsize_t)poff; - poffb=poffa+sizeof(uint64); - if (((uint64)poffa!=poff)||(poffb<poffa)||(poffb<(tmsize_t)sizeof(uint64))||(poffb>tif->tif_size)) + poffb=poffa+sizeof(uint64_t); + if (((uint64_t)poffa != poff) || (poffb < poffa) || (poffb < (tmsize_t)sizeof(uint64_t)) || (poffb > tif->tif_size)) { TIFFErrorExt(tif->tif_clientdata,module,"Error fetching directory count"); return(0); } - _TIFFmemcpy(&dircount64,tif->tif_base+poffa,sizeof(uint64)); + _TIFFmemcpy(&dircount64,tif->tif_base+poffa,sizeof(uint64_t)); if (tif->tif_flags&TIFF_SWAB) TIFFSwabLong8(&dircount64); if (dircount64>0xFFFF) @@ -1546,17 +1546,17 @@ TIFFAdvanceDirectory(TIFF* tif, uint64* nextdir, uint64* off) TIFFErrorExt(tif->tif_clientdata,module,"Sanity check on directory count failed"); return(0); } - dircount16=(uint16)dircount64; + dircount16=(uint16_t)dircount64; poffc=poffb+dircount16*20; - poffd=poffc+sizeof(uint64); - if ((poffc<poffb)||(poffc<dircount16*20)||(poffd<poffc)||(poffd<(tmsize_t)sizeof(uint64))||(poffd>tif->tif_size)) + poffd=poffc+sizeof(uint64_t); + if ((poffc<poffb) || (poffc<dircount16*20) || (poffd<poffc) || (poffd<(tmsize_t)sizeof(uint64_t)) || (poffd > tif->tif_size)) { TIFFErrorExt(tif->tif_clientdata,module,"Error fetching directory link"); return(0); } if (off!=NULL) - *off=(uint64)poffc; - _TIFFmemcpy(nextdir,tif->tif_base+poffc,sizeof(uint64)); + *off=(uint64_t)poffc; + _TIFFmemcpy(nextdir,tif->tif_base+poffc,sizeof(uint64_t)); if (tif->tif_flags&TIFF_SWAB) TIFFSwabLong8(nextdir); } @@ -1566,10 +1566,10 @@ TIFFAdvanceDirectory(TIFF* tif, uint64* nextdir, uint64* off) { if (!(tif->tif_flags&TIFF_BIGTIFF)) { - uint16 dircount; - uint32 nextdir32; + uint16_t dircount; + uint32_t nextdir32; if (!SeekOK(tif, *nextdir) || - !ReadOK(tif, &dircount, sizeof (uint16))) { + !ReadOK(tif, &dircount, sizeof (uint16_t))) { TIFFErrorExt(tif->tif_clientdata, module, "%s: Error fetching directory count", tif->tif_name); return (0); @@ -1582,7 +1582,7 @@ TIFFAdvanceDirectory(TIFF* tif, uint64* nextdir, uint64* off) else (void) TIFFSeekFile(tif, dircount*12, SEEK_CUR); - if (!ReadOK(tif, &nextdir32, sizeof (uint32))) { + if (!ReadOK(tif, &nextdir32, sizeof (uint32_t))) { TIFFErrorExt(tif->tif_clientdata, module, "%s: Error fetching directory link", tif->tif_name); return (0); @@ -1593,10 +1593,10 @@ TIFFAdvanceDirectory(TIFF* tif, uint64* nextdir, uint64* off) } else { - uint64 dircount64; - uint16 dircount16; + uint64_t dircount64; + uint16_t dircount16; if (!SeekOK(tif, *nextdir) || - !ReadOK(tif, &dircount64, sizeof (uint64))) { + !ReadOK(tif, &dircount64, sizeof (uint64_t))) { TIFFErrorExt(tif->tif_clientdata, module, "%s: Error fetching directory count", tif->tif_name); return (0); @@ -1608,14 +1608,14 @@ TIFFAdvanceDirectory(TIFF* tif, uint64* nextdir, uint64* off) TIFFErrorExt(tif->tif_clientdata, module, "Error fetching directory count"); return(0); } - dircount16 = (uint16)dircount64; + dircount16 = (uint16_t)dircount64; if (off != NULL) *off = TIFFSeekFile(tif, dircount16*20, SEEK_CUR); else (void) TIFFSeekFile(tif, dircount16*20, SEEK_CUR); - if (!ReadOK(tif, nextdir, sizeof (uint64))) { + if (!ReadOK(tif, nextdir, sizeof (uint64_t))) { TIFFErrorExt(tif->tif_clientdata, module, "%s: Error fetching directory link", tif->tif_name); @@ -1631,12 +1631,12 @@ TIFFAdvanceDirectory(TIFF* tif, uint64* nextdir, uint64* off) /* * Count the number of directories in a file. */ -uint16 +uint16_t TIFFNumberOfDirectories(TIFF* tif) { static const char module[] = "TIFFNumberOfDirectories"; - uint64 nextdir; - uint16 n; + uint64_t nextdir; + uint16_t n; if (!(tif->tif_flags&TIFF_BIGTIFF)) nextdir = tif->tif_header.classic.tiff_diroff; else @@ -1663,10 +1663,10 @@ TIFFNumberOfDirectories(TIFF* tif) * NB: Directories are numbered starting at 0. */ int -TIFFSetDirectory(TIFF* tif, uint16 dirn) +TIFFSetDirectory(TIFF* tif, uint16_t dirn) { - uint64 nextdir; - uint16 n; + uint64_t nextdir; + uint16_t n; if (!(tif->tif_flags&TIFF_BIGTIFF)) nextdir = tif->tif_header.classic.tiff_diroff; @@ -1697,7 +1697,7 @@ TIFFSetDirectory(TIFF* tif, uint16 dirn) * the SubIFD tag (e.g. thumbnail images). */ int -TIFFSetSubDirectory(TIFF* tif, uint64 diroff) +TIFFSetSubDirectory(TIFF* tif, uint64_t diroff) { tif->tif_nextdiroff = diroff; /* @@ -1711,7 +1711,7 @@ TIFFSetSubDirectory(TIFF* tif, uint64 diroff) /* * Return file offset of the current directory. */ -uint64 +uint64_t TIFFCurrentDirOffset(TIFF* tif) { return (tif->tif_diroff); @@ -1731,12 +1731,12 @@ TIFFLastDirectory(TIFF* tif) * Unlink the specified directory from the directory chain. */ int -TIFFUnlinkDirectory(TIFF* tif, uint16 dirn) +TIFFUnlinkDirectory(TIFF* tif, uint16_t dirn) { static const char module[] = "TIFFUnlinkDirectory"; - uint64 nextdir; - uint64 off; - uint16 n; + uint64_t nextdir; + uint64_t off; + uint16_t n; if (tif->tif_mode == O_RDONLY) { TIFFErrorExt(tif->tif_clientdata, module, @@ -1760,7 +1760,7 @@ TIFFUnlinkDirectory(TIFF* tif, uint16 dirn) } for (n = dirn-1; n > 0; n--) { if (nextdir == 0) { - TIFFErrorExt(tif->tif_clientdata, module, "Directory %d does not exist", dirn); + TIFFErrorExt(tif->tif_clientdata, module, "Directory %"PRIu16" does not exist", dirn); return (0); } if (!TIFFAdvanceDirectory(tif, &nextdir, &off)) @@ -1780,12 +1780,12 @@ TIFFUnlinkDirectory(TIFF* tif, uint16 dirn) (void) TIFFSeekFile(tif, off, SEEK_SET); if (!(tif->tif_flags&TIFF_BIGTIFF)) { - uint32 nextdir32; - nextdir32=(uint32)nextdir; - assert((uint64)nextdir32==nextdir); + uint32_t nextdir32; + nextdir32=(uint32_t)nextdir; + assert((uint64_t)nextdir32 == nextdir); if (tif->tif_flags & TIFF_SWAB) TIFFSwabLong(&nextdir32); - if (!WriteOK(tif, &nextdir32, sizeof (uint32))) { + if (!WriteOK(tif, &nextdir32, sizeof (uint32_t))) { TIFFErrorExt(tif->tif_clientdata, module, "Error writing directory link"); return (0); } @@ -1794,7 +1794,7 @@ TIFFUnlinkDirectory(TIFF* tif, uint16 dirn) { if (tif->tif_flags & TIFF_SWAB) TIFFSwabLong8(&nextdir); - if (!WriteOK(tif, &nextdir, sizeof (uint64))) { + if (!WriteOK(tif, &nextdir, sizeof (uint64_t))) { TIFFErrorExt(tif->tif_clientdata, module, "Error writing directory link"); return (0); } @@ -1820,8 +1820,8 @@ TIFFUnlinkDirectory(TIFF* tif, uint16 dirn) tif->tif_diroff = 0; /* force link on next write */ tif->tif_nextdiroff = 0; /* next write must be at end */ tif->tif_curoff = 0; - tif->tif_row = (uint32) -1; - tif->tif_curstrip = (uint32) -1; + tif->tif_row = (uint32_t) -1; + tif->tif_curstrip = (uint32_t) -1; return (1); } diff --git a/tiff/libtiff/tif_dir.h b/tiff/libtiff/tif_dir.h index f608dd71..1782b35d 100644 --- a/tiff/libtiff/tif_dir.h +++ b/tiff/libtiff/tif_dir.h @@ -50,15 +50,15 @@ typedef struct { * it is left-justified in the offset field. */ typedef struct { - uint16 tdir_tag; /* see below */ - uint16 tdir_type; /* data type; see below */ - uint64 tdir_count; /* number of items; length in spec */ + uint16_t tdir_tag; /* see below */ + uint16_t tdir_type; /* data type; see below */ + uint64_t tdir_count; /* number of items; length in spec */ union { - uint16 toff_short; - uint32 toff_long; - uint64 toff_long8; + uint16_t toff_short; + uint32_t toff_long; + uint64_t toff_long8; } tdir_offset; /* either offset or the data itself if fits */ - uint8 tdir_ignore; /* flag status to ignore tag when parsing tags in tif_dirread.c */ + uint8_t tdir_ignore; /* flag status to ignore tag when parsing tags in tif_dirread.c */ } TIFFDirEntry; /* @@ -69,50 +69,50 @@ 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; + uint32_t td_imagewidth, td_imagelength, td_imagedepth; + uint32_t td_tilewidth, td_tilelength, td_tiledepth; + uint32_t td_subfiletype; + uint16_t td_bitspersample; + uint16_t td_sampleformat; + uint16_t td_compression; + uint16_t td_photometric; + uint16_t td_threshholding; + uint16_t td_fillorder; + uint16_t td_orientation; + uint16_t td_samplesperpixel; + uint32_t td_rowsperstrip; + uint16_t td_minsamplevalue, td_maxsamplevalue; double* td_sminsamplevalue; double* td_smaxsamplevalue; float td_xresolution, td_yresolution; - uint16 td_resolutionunit; - uint16 td_planarconfig; + uint16_t td_resolutionunit; + uint16_t 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; + uint16_t td_pagenumber[2]; + uint16_t* td_colormap[3]; + uint16_t td_halftonehints[2]; + uint16_t td_extrasamples; + uint16_t* td_sampleinfo; /* even though the name is misleading, td_stripsperimage is the number * of striles (=strips or tiles) per plane, and td_nstrips the total * number of striles */ - uint32 td_stripsperimage; - uint32 td_nstrips; /* size of offset & bytecount arrays */ - uint64* td_stripoffset_p; /* should be accessed with TIFFGetStrileOffset */ - uint64* td_stripbytecount_p; /* should be accessed with TIFFGetStrileByteCount */ - uint32 td_stripoffsetbyteallocsize; /* number of elements currently allocated for td_stripoffset/td_stripbytecount. Only used if TIFF_LAZYSTRILELOAD is set */ + uint32_t td_stripsperimage; + uint32_t td_nstrips; /* size of offset & bytecount arrays */ + uint64_t* td_stripoffset_p; /* should be accessed with TIFFGetStrileOffset */ + uint64_t* td_stripbytecount_p; /* should be accessed with TIFFGetStrileByteCount */ + uint32_t td_stripoffsetbyteallocsize; /* number of elements currently allocated for td_stripoffset/td_stripbytecount. Only used if TIFF_LAZYSTRILELOAD is set */ #ifdef STRIPBYTECOUNTSORTED_UNUSED int td_stripbytecountsorted; /* is the bytecount array sorted ascending? */ #endif TIFFDirEntry td_stripoffset_entry; /* for deferred loading */ TIFFDirEntry td_stripbytecount_entry; /* for deferred loading */ - uint16 td_nsubifd; - uint64* td_subifd; + uint16_t td_nsubifd; + uint64_t* td_subifd; /* YCbCr parameters */ - uint16 td_ycbcrsubsampling[2]; - uint16 td_ycbcrpositioning; + uint16_t td_ycbcrsubsampling[2]; + uint16_t td_ycbcrpositioning; /* Colorimetry parameters */ - uint16* td_transferfunction[3]; + uint16_t* td_transferfunction[3]; float* td_refblackwhite; /* CMYK parameters */ int td_inknameslen; @@ -276,17 +276,17 @@ typedef enum { struct _TIFFFieldArray { TIFFFieldArrayType type; /* array type, will be used to determine if IFD is image and such */ - uint32 allocated_size; /* 0 if array is constant, other if modified by future definition extension support */ - uint32 count; /* number of elements in fields array */ + uint32_t allocated_size; /* 0 if array is constant, other if modified by future definition extension support */ + uint32_t count; /* number of elements in fields array */ TIFFField* fields; /* actual field info */ }; struct _TIFFField { - uint32 field_tag; /* field's tag */ + uint32_t field_tag; /* field's tag */ short field_readcount; /* read count/TIFF_VARIABLE/TIFF_SPP */ short field_writecount; /* write count/TIFF_VARIABLE */ TIFFDataType field_type; /* type of associated data */ - uint32 reserved; /* reserved for future extension */ + uint32_t reserved; /* reserved for future extension */ TIFFSetGetFieldType set_field_type; /* type to be passed to TIFFSetField */ TIFFSetGetFieldType get_field_type; /* type to be passed to TIFFGetField */ unsigned short field_bit; /* bit in fieldsset bit vector */ @@ -296,9 +296,9 @@ struct _TIFFField { TIFFFieldArray* field_subfields; /* if field points to child ifds, child ifd field definition array */ }; -extern int _TIFFMergeFields(TIFF*, const TIFFField[], uint32); -extern const TIFFField* _TIFFFindOrRegisterField(TIFF *, uint32, TIFFDataType); -extern TIFFField* _TIFFCreateAnonField(TIFF *, uint32, TIFFDataType); +extern int _TIFFMergeFields(TIFF*, const TIFFField[], uint32_t); +extern const TIFFField* _TIFFFindOrRegisterField(TIFF *, uint32_t, TIFFDataType); +extern TIFFField* _TIFFCreateAnonField(TIFF *, uint32_t, TIFFDataType); extern int _TIFFCheckFieldIsValidForCodec(TIFF *tif, ttag_t tag); #if defined(__cplusplus) diff --git a/tiff/libtiff/tif_dirinfo.c b/tiff/libtiff/tif_dirinfo.c index 7217042c..8565dfbc 100644 --- a/tiff/libtiff/tif_dirinfo.c +++ b/tiff/libtiff/tif_dirinfo.c @@ -325,7 +325,7 @@ exifFields[] = { * EXIF-GPS tags (Version 2.31, July 2016; nothing changed for version 2.32 May 2019) */ -static TIFFField +static const TIFFField gpsFields[] = { /* For the GPS tag definitions in gpsFields[] the standard definition for Rationals is TIFF_SETGET_DOUBLE and TIFF_SETGET_C0_FLOAT. *-- ATTENTION: After the upgrade with Rational2Double, the GPSTAG values can now be written and also read in double precision! @@ -415,7 +415,7 @@ void _TIFFSetupFields(TIFF* tif, const TIFFFieldArray* fieldarray) { if (tif->tif_fields && tif->tif_nfields > 0) { - uint32 i; + uint32_t i; for (i = 0; i < tif->tif_nfields; i++) { TIFFField *fld = tif->tif_fields[i]; @@ -464,12 +464,12 @@ tagNameCompare(const void* a, const void* b) } int -_TIFFMergeFields(TIFF* tif, const TIFFField info[], uint32 n) +_TIFFMergeFields(TIFF* tif, const TIFFField info[], uint32_t n) { static const char module[] = "_TIFFMergeFields"; static const char reason[] = "for fields array"; /* TIFFField** tp; */ - uint32 i; + uint32_t i; tif->tif_foundfield = NULL; @@ -511,7 +511,7 @@ _TIFFMergeFields(TIFF* tif, const TIFFField info[], uint32 n) void _TIFFPrintFieldInfo(TIFF* tif, FILE* fd) { - uint32 i; + uint32_t i; fprintf(fd, "%s: \n", tif->tif_name); for (i = 0; i < tif->tif_nfields; i++) { @@ -677,7 +677,7 @@ _TIFFSetGetFieldSize(TIFFSetGetFieldType setgettype) const TIFFField* -TIFFFindField(TIFF* tif, uint32 tag, TIFFDataType dt) +TIFFFindField(TIFF* tif, uint32_t tag, TIFFDataType dt) { TIFFField key = {0, 0, 0, TIFF_NOTYPE, 0, 0, 0, 0, 0, 0, NULL, NULL}; TIFFField* pkey = &key; @@ -729,7 +729,7 @@ _TIFFFindFieldByName(TIFF* tif, const char *field_name, TIFFDataType dt) } const TIFFField* -TIFFFieldWithTag(TIFF* tif, uint32 tag) +TIFFFieldWithTag(TIFF* tif, uint32_t tag) { const TIFFField* fip = TIFFFindField(tif, tag, TIFF_ANY); if (!fip) { @@ -752,7 +752,7 @@ TIFFFieldWithName(TIFF* tif, const char *field_name) return (fip); } -uint32 +uint32_t TIFFFieldTag(const TIFFField* fip) { return fip->field_tag; @@ -789,7 +789,7 @@ TIFFFieldWriteCount(const TIFFField* fip) } const TIFFField* -_TIFFFindOrRegisterField(TIFF *tif, uint32 tag, TIFFDataType dt) +_TIFFFindOrRegisterField(TIFF *tif, uint32_t tag, TIFFDataType dt) { const TIFFField *fld; @@ -805,7 +805,7 @@ _TIFFFindOrRegisterField(TIFF *tif, uint32 tag, TIFFDataType dt) } TIFFField* -_TIFFCreateAnonField(TIFF *tif, uint32 tag, TIFFDataType field_type) +_TIFFCreateAnonField(TIFF *tif, uint32_t tag, TIFFDataType field_type) { TIFFField *fld; (void) tif; @@ -1059,13 +1059,13 @@ _TIFFSetGetType(TIFFDataType type, short count, unsigned char passcount) } int -TIFFMergeFieldInfo(TIFF* tif, const TIFFFieldInfo info[], uint32 n) +TIFFMergeFieldInfo(TIFF* tif, const TIFFFieldInfo info[], uint32_t n) { static const char module[] = "TIFFMergeFieldInfo"; static const char reason[] = "for fields array"; TIFFField *tp; size_t nfields; - uint32 i; + uint32_t i; if (tif->tif_nfieldscompat > 0) { tif->tif_fieldscompat = (TIFFFieldArray *) diff --git a/tiff/libtiff/tif_dirread.c b/tiff/libtiff/tif_dirread.c index ba127ca9..d84147a0 100644 --- a/tiff/libtiff/tif_dirread.c +++ b/tiff/libtiff/tif_dirread.c @@ -34,23 +34,19 @@ * TIFFReadDirectory, so as to eliminate current possibly repetitive lookup. */ +#include "tiffconf.h" #include "tiffiop.h" #include <float.h> #include <stdlib.h> -#define FAILED_FII ((uint32) -1) - -/* - * Largest 64-bit signed integer value. - */ -#define TIFF_INT64_MAX ((int64)(TIFF_UINT64_MAX >> 1)) +#define FAILED_FII ((uint32_t) -1) #ifdef HAVE_IEEEFP # define TIFFCvtIEEEFloatToNative(tif, n, fp) # define TIFFCvtIEEEDoubleToNative(tif, n, dp) #else -extern void TIFFCvtIEEEFloatToNative(TIFF*, uint32, float*); -extern void TIFFCvtIEEEDoubleToNative(TIFF*, uint32, double*); +extern void TIFFCvtIEEEFloatToNative(TIFF*, uint32_t, float*); +extern void TIFFCvtIEEEDoubleToNative(TIFF*, uint32_t, double*); #endif enum TIFFReadDirEntryErr { @@ -64,126 +60,126 @@ enum TIFFReadDirEntryErr { TIFFReadDirEntryErrAlloc = 7, }; -static enum TIFFReadDirEntryErr TIFFReadDirEntryByte(TIFF* tif, TIFFDirEntry* direntry, uint8* value); -static enum TIFFReadDirEntryErr TIFFReadDirEntryShort(TIFF* tif, TIFFDirEntry* direntry, uint16* value); -static enum TIFFReadDirEntryErr TIFFReadDirEntryLong(TIFF* tif, TIFFDirEntry* direntry, uint32* value); -static enum TIFFReadDirEntryErr TIFFReadDirEntryLong8(TIFF* tif, TIFFDirEntry* direntry, uint64* value); +static enum TIFFReadDirEntryErr TIFFReadDirEntryByte(TIFF* tif, TIFFDirEntry* direntry, uint8_t* value); +static enum TIFFReadDirEntryErr TIFFReadDirEntryShort(TIFF* tif, TIFFDirEntry* direntry, uint16_t* value); +static enum TIFFReadDirEntryErr TIFFReadDirEntryLong(TIFF* tif, TIFFDirEntry* direntry, uint32_t* value); +static enum TIFFReadDirEntryErr TIFFReadDirEntryLong8(TIFF* tif, TIFFDirEntry* direntry, uint64_t* value); static enum TIFFReadDirEntryErr TIFFReadDirEntryFloat(TIFF* tif, TIFFDirEntry* direntry, float* value); static enum TIFFReadDirEntryErr TIFFReadDirEntryDouble(TIFF* tif, TIFFDirEntry* direntry, double* value); -static enum TIFFReadDirEntryErr TIFFReadDirEntryIfd8(TIFF* tif, TIFFDirEntry* direntry, uint64* value); - -static enum TIFFReadDirEntryErr TIFFReadDirEntryArray(TIFF* tif, TIFFDirEntry* direntry, uint32* count, uint32 desttypesize, void** value); -static enum TIFFReadDirEntryErr TIFFReadDirEntryByteArray(TIFF* tif, TIFFDirEntry* direntry, uint8** value); -static enum TIFFReadDirEntryErr TIFFReadDirEntrySbyteArray(TIFF* tif, TIFFDirEntry* direntry, int8** value); -static enum TIFFReadDirEntryErr TIFFReadDirEntryShortArray(TIFF* tif, TIFFDirEntry* direntry, uint16** value); -static enum TIFFReadDirEntryErr TIFFReadDirEntrySshortArray(TIFF* tif, TIFFDirEntry* direntry, int16** value); -static enum TIFFReadDirEntryErr TIFFReadDirEntryLongArray(TIFF* tif, TIFFDirEntry* direntry, uint32** value); -static enum TIFFReadDirEntryErr TIFFReadDirEntrySlongArray(TIFF* tif, TIFFDirEntry* direntry, int32** value); -static enum TIFFReadDirEntryErr TIFFReadDirEntryLong8Array(TIFF* tif, TIFFDirEntry* direntry, uint64** value); -static enum TIFFReadDirEntryErr TIFFReadDirEntrySlong8Array(TIFF* tif, TIFFDirEntry* direntry, int64** value); +static enum TIFFReadDirEntryErr TIFFReadDirEntryIfd8(TIFF* tif, TIFFDirEntry* direntry, uint64_t* value); + +static enum TIFFReadDirEntryErr TIFFReadDirEntryArray(TIFF* tif, TIFFDirEntry* direntry, uint32_t* count, uint32_t desttypesize, void** value); +static enum TIFFReadDirEntryErr TIFFReadDirEntryByteArray(TIFF* tif, TIFFDirEntry* direntry, uint8_t** value); +static enum TIFFReadDirEntryErr TIFFReadDirEntrySbyteArray(TIFF* tif, TIFFDirEntry* direntry, int8_t** value); +static enum TIFFReadDirEntryErr TIFFReadDirEntryShortArray(TIFF* tif, TIFFDirEntry* direntry, uint16_t** value); +static enum TIFFReadDirEntryErr TIFFReadDirEntrySshortArray(TIFF* tif, TIFFDirEntry* direntry, int16_t** value); +static enum TIFFReadDirEntryErr TIFFReadDirEntryLongArray(TIFF* tif, TIFFDirEntry* direntry, uint32_t** value); +static enum TIFFReadDirEntryErr TIFFReadDirEntrySlongArray(TIFF* tif, TIFFDirEntry* direntry, int32_t** value); +static enum TIFFReadDirEntryErr TIFFReadDirEntryLong8Array(TIFF* tif, TIFFDirEntry* direntry, uint64_t** value); +static enum TIFFReadDirEntryErr TIFFReadDirEntrySlong8Array(TIFF* tif, TIFFDirEntry* direntry, int64_t** value); static enum TIFFReadDirEntryErr TIFFReadDirEntryFloatArray(TIFF* tif, TIFFDirEntry* direntry, float** value); static enum TIFFReadDirEntryErr TIFFReadDirEntryDoubleArray(TIFF* tif, TIFFDirEntry* direntry, double** value); -static enum TIFFReadDirEntryErr TIFFReadDirEntryIfd8Array(TIFF* tif, TIFFDirEntry* direntry, uint64** value); +static enum TIFFReadDirEntryErr TIFFReadDirEntryIfd8Array(TIFF* tif, TIFFDirEntry* direntry, uint64_t** value); -static enum TIFFReadDirEntryErr TIFFReadDirEntryPersampleShort(TIFF* tif, TIFFDirEntry* direntry, uint16* value); +static enum TIFFReadDirEntryErr TIFFReadDirEntryPersampleShort(TIFF* tif, TIFFDirEntry* direntry, uint16_t* value); #if 0 static enum TIFFReadDirEntryErr TIFFReadDirEntryPersampleDouble(TIFF* tif, TIFFDirEntry* direntry, double* value); #endif -static void TIFFReadDirEntryCheckedByte(TIFF* tif, TIFFDirEntry* direntry, uint8* value); -static void TIFFReadDirEntryCheckedSbyte(TIFF* tif, TIFFDirEntry* direntry, int8* value); -static void TIFFReadDirEntryCheckedShort(TIFF* tif, TIFFDirEntry* direntry, uint16* value); -static void TIFFReadDirEntryCheckedSshort(TIFF* tif, TIFFDirEntry* direntry, int16* value); -static void TIFFReadDirEntryCheckedLong(TIFF* tif, TIFFDirEntry* direntry, uint32* value); -static void TIFFReadDirEntryCheckedSlong(TIFF* tif, TIFFDirEntry* direntry, int32* value); -static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckedLong8(TIFF* tif, TIFFDirEntry* direntry, uint64* value); -static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckedSlong8(TIFF* tif, TIFFDirEntry* direntry, int64* value); +static void TIFFReadDirEntryCheckedByte(TIFF* tif, TIFFDirEntry* direntry, uint8_t* value); +static void TIFFReadDirEntryCheckedSbyte(TIFF* tif, TIFFDirEntry* direntry, int8_t* value); +static void TIFFReadDirEntryCheckedShort(TIFF* tif, TIFFDirEntry* direntry, uint16_t* value); +static void TIFFReadDirEntryCheckedSshort(TIFF* tif, TIFFDirEntry* direntry, int16_t* value); +static void TIFFReadDirEntryCheckedLong(TIFF* tif, TIFFDirEntry* direntry, uint32_t* value); +static void TIFFReadDirEntryCheckedSlong(TIFF* tif, TIFFDirEntry* direntry, int32_t* value); +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckedLong8(TIFF* tif, TIFFDirEntry* direntry, uint64_t* value); +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckedSlong8(TIFF* tif, TIFFDirEntry* direntry, int64_t* value); static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckedRational(TIFF* tif, TIFFDirEntry* direntry, double* value); static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckedSrational(TIFF* tif, TIFFDirEntry* direntry, double* value); static void TIFFReadDirEntryCheckedFloat(TIFF* tif, TIFFDirEntry* direntry, float* value); static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckedDouble(TIFF* tif, TIFFDirEntry* direntry, double* value); -static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeByteSbyte(int8 value); -static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeByteShort(uint16 value); -static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeByteSshort(int16 value); -static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeByteLong(uint32 value); -static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeByteSlong(int32 value); -static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeByteLong8(uint64 value); -static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeByteSlong8(int64 value); - -static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSbyteByte(uint8 value); -static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSbyteShort(uint16 value); -static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSbyteSshort(int16 value); -static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSbyteLong(uint32 value); -static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSbyteSlong(int32 value); -static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSbyteLong8(uint64 value); -static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSbyteSlong8(int64 value); - -static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeShortSbyte(int8 value); -static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeShortSshort(int16 value); -static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeShortLong(uint32 value); -static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeShortSlong(int32 value); -static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeShortLong8(uint64 value); -static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeShortSlong8(int64 value); - -static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSshortShort(uint16 value); -static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSshortLong(uint32 value); -static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSshortSlong(int32 value); -static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSshortLong8(uint64 value); -static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSshortSlong8(int64 value); - -static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeLongSbyte(int8 value); -static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeLongSshort(int16 value); -static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeLongSlong(int32 value); -static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeLongLong8(uint64 value); -static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeLongSlong8(int64 value); - -static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSlongLong(uint32 value); -static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSlongLong8(uint64 value); -static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSlongSlong8(int64 value); - -static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeLong8Sbyte(int8 value); -static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeLong8Sshort(int16 value); -static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeLong8Slong(int32 value); -static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeLong8Slong8(int64 value); - -static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSlong8Long8(uint64 value); - -static enum TIFFReadDirEntryErr TIFFReadDirEntryData(TIFF* tif, uint64 offset, tmsize_t size, void* dest); +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeByteSbyte(int8_t value); +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeByteShort(uint16_t value); +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeByteSshort(int16_t value); +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeByteLong(uint32_t value); +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeByteSlong(int32_t value); +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeByteLong8(uint64_t value); +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeByteSlong8(int64_t value); + +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSbyteByte(uint8_t value); +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSbyteShort(uint16_t value); +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSbyteSshort(int16_t value); +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSbyteLong(uint32_t value); +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSbyteSlong(int32_t value); +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSbyteLong8(uint64_t value); +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSbyteSlong8(int64_t value); + +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeShortSbyte(int8_t value); +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeShortSshort(int16_t value); +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeShortLong(uint32_t value); +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeShortSlong(int32_t value); +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeShortLong8(uint64_t value); +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeShortSlong8(int64_t value); + +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSshortShort(uint16_t value); +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSshortLong(uint32_t value); +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSshortSlong(int32_t value); +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSshortLong8(uint64_t value); +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSshortSlong8(int64_t value); + +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeLongSbyte(int8_t value); +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeLongSshort(int16_t value); +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeLongSlong(int32_t value); +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeLongLong8(uint64_t value); +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeLongSlong8(int64_t value); + +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSlongLong(uint32_t value); +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSlongLong8(uint64_t value); +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSlongSlong8(int64_t value); + +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeLong8Sbyte(int8_t value); +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeLong8Sshort(int16_t value); +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeLong8Slong(int32_t value); +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeLong8Slong8(int64_t value); + +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSlong8Long8(uint64_t value); + +static enum TIFFReadDirEntryErr TIFFReadDirEntryData(TIFF* tif, uint64_t offset, tmsize_t size, void* dest); static void TIFFReadDirEntryOutputErr(TIFF* tif, enum TIFFReadDirEntryErr err, const char* module, const char* tagname, int recover); -static void TIFFReadDirectoryCheckOrder(TIFF* tif, TIFFDirEntry* dir, uint16 dircount); -static TIFFDirEntry* TIFFReadDirectoryFindEntry(TIFF* tif, TIFFDirEntry* dir, uint16 dircount, uint16 tagid); -static void TIFFReadDirectoryFindFieldInfo(TIFF* tif, uint16 tagid, uint32* fii); +static void TIFFReadDirectoryCheckOrder(TIFF* tif, TIFFDirEntry* dir, uint16_t dircount); +static TIFFDirEntry* TIFFReadDirectoryFindEntry(TIFF* tif, TIFFDirEntry* dir, uint16_t dircount, uint16_t tagid); +static void TIFFReadDirectoryFindFieldInfo(TIFF* tif, uint16_t tagid, uint32_t* fii); -static int EstimateStripByteCounts(TIFF* tif, TIFFDirEntry* dir, uint16 dircount); +static int EstimateStripByteCounts(TIFF* tif, TIFFDirEntry* dir, uint16_t dircount); static void MissingRequired(TIFF*, const char*); -static int TIFFCheckDirOffset(TIFF* tif, uint64 diroff); -static int CheckDirCount(TIFF*, TIFFDirEntry*, uint32); -static uint16 TIFFFetchDirectory(TIFF* tif, uint64 diroff, TIFFDirEntry** pdir, uint64* nextdiroff); +static int TIFFCheckDirOffset(TIFF* tif, uint64_t diroff); +static int CheckDirCount(TIFF*, TIFFDirEntry*, uint32_t); +static uint16_t TIFFFetchDirectory(TIFF* tif, uint64_t diroff, TIFFDirEntry** pdir, uint64_t* nextdiroff); static int TIFFFetchNormalTag(TIFF*, TIFFDirEntry*, int recover); -static int TIFFFetchStripThing(TIFF* tif, TIFFDirEntry* dir, uint32 nstrips, uint64** lpp); +static int TIFFFetchStripThing(TIFF* tif, TIFFDirEntry* dir, uint32_t nstrips, uint64_t** lpp); static int TIFFFetchSubjectDistance(TIFF*, TIFFDirEntry*); static void ChopUpSingleUncompressedStrip(TIFF*); static void TryChopUpUncompressedBigTiff(TIFF*); -static uint64 TIFFReadUInt64(const uint8 *value); -static int _TIFFGetMaxColorChannels(uint16 photometric); +static uint64_t TIFFReadUInt64(const uint8_t *value); +static int _TIFFGetMaxColorChannels(uint16_t photometric); static int _TIFFFillStrilesInternal( TIFF *tif, int loadStripByteCount ); typedef union _UInt64Aligned_t { double d; - uint64 l; - uint32 i[2]; - uint16 s[4]; - uint8 c[8]; + uint64_t l; + uint32_t i[2]; + uint16_t s[4]; + uint8_t c[8]; } UInt64Aligned_t; /* - Unaligned safe copy of a uint64 value from an octet array. + Unaligned safe copy of a uint64_t value from an octet array. */ -static uint64 TIFFReadUInt64(const uint8 *value) +static uint64_t TIFFReadUInt64(const uint8_t *value) { UInt64Aligned_t result; @@ -199,7 +195,7 @@ static uint64 TIFFReadUInt64(const uint8 *value) return result.l; } -static enum TIFFReadDirEntryErr TIFFReadDirEntryByte(TIFF* tif, TIFFDirEntry* direntry, uint8* value) +static enum TIFFReadDirEntryErr TIFFReadDirEntryByte(TIFF* tif, TIFFDirEntry* direntry, uint8_t* value) { enum TIFFReadDirEntryErr err; if (direntry->tdir_count!=1) @@ -212,76 +208,76 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryByte(TIFF* tif, TIFFDirEntry* di return(TIFFReadDirEntryErrOk); case TIFF_SBYTE: { - int8 m; + int8_t m; TIFFReadDirEntryCheckedSbyte(tif,direntry,&m); err=TIFFReadDirEntryCheckRangeByteSbyte(m); if (err!=TIFFReadDirEntryErrOk) return(err); - *value=(uint8)m; + *value=(uint8_t)m; return(TIFFReadDirEntryErrOk); } case TIFF_SHORT: { - uint16 m; + uint16_t m; TIFFReadDirEntryCheckedShort(tif,direntry,&m); err=TIFFReadDirEntryCheckRangeByteShort(m); if (err!=TIFFReadDirEntryErrOk) return(err); - *value=(uint8)m; + *value=(uint8_t)m; return(TIFFReadDirEntryErrOk); } case TIFF_SSHORT: { - int16 m; + int16_t m; TIFFReadDirEntryCheckedSshort(tif,direntry,&m); err=TIFFReadDirEntryCheckRangeByteSshort(m); if (err!=TIFFReadDirEntryErrOk) return(err); - *value=(uint8)m; + *value=(uint8_t)m; return(TIFFReadDirEntryErrOk); } case TIFF_LONG: { - uint32 m; + uint32_t m; TIFFReadDirEntryCheckedLong(tif,direntry,&m); err=TIFFReadDirEntryCheckRangeByteLong(m); if (err!=TIFFReadDirEntryErrOk) return(err); - *value=(uint8)m; + *value=(uint8_t)m; return(TIFFReadDirEntryErrOk); } case TIFF_SLONG: { - int32 m; + int32_t m; TIFFReadDirEntryCheckedSlong(tif,direntry,&m); err=TIFFReadDirEntryCheckRangeByteSlong(m); if (err!=TIFFReadDirEntryErrOk) return(err); - *value=(uint8)m; + *value=(uint8_t)m; return(TIFFReadDirEntryErrOk); } case TIFF_LONG8: { - uint64 m; + uint64_t m; err=TIFFReadDirEntryCheckedLong8(tif,direntry,&m); if (err!=TIFFReadDirEntryErrOk) return(err); err=TIFFReadDirEntryCheckRangeByteLong8(m); if (err!=TIFFReadDirEntryErrOk) return(err); - *value=(uint8)m; + *value=(uint8_t)m; return(TIFFReadDirEntryErrOk); } case TIFF_SLONG8: { - int64 m; + int64_t m; err=TIFFReadDirEntryCheckedSlong8(tif,direntry,&m); if (err!=TIFFReadDirEntryErrOk) return(err); err=TIFFReadDirEntryCheckRangeByteSlong8(m); if (err!=TIFFReadDirEntryErrOk) return(err); - *value=(uint8)m; + *value=(uint8_t)m; return(TIFFReadDirEntryErrOk); } default: @@ -289,7 +285,7 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryByte(TIFF* tif, TIFFDirEntry* di } } -static enum TIFFReadDirEntryErr TIFFReadDirEntryShort(TIFF* tif, TIFFDirEntry* direntry, uint16* value) +static enum TIFFReadDirEntryErr TIFFReadDirEntryShort(TIFF* tif, TIFFDirEntry* direntry, uint16_t* value) { enum TIFFReadDirEntryErr err; if (direntry->tdir_count!=1) @@ -298,19 +294,19 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryShort(TIFF* tif, TIFFDirEntry* d { case TIFF_BYTE: { - uint8 m; + uint8_t m; TIFFReadDirEntryCheckedByte(tif,direntry,&m); - *value=(uint16)m; + *value=(uint16_t)m; return(TIFFReadDirEntryErrOk); } case TIFF_SBYTE: { - int8 m; + int8_t m; TIFFReadDirEntryCheckedSbyte(tif,direntry,&m); err=TIFFReadDirEntryCheckRangeShortSbyte(m); if (err!=TIFFReadDirEntryErrOk) return(err); - *value=(uint16)m; + *value=(uint16_t)m; return(TIFFReadDirEntryErrOk); } case TIFF_SHORT: @@ -318,56 +314,56 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryShort(TIFF* tif, TIFFDirEntry* d return(TIFFReadDirEntryErrOk); case TIFF_SSHORT: { - int16 m; + int16_t m; TIFFReadDirEntryCheckedSshort(tif,direntry,&m); err=TIFFReadDirEntryCheckRangeShortSshort(m); if (err!=TIFFReadDirEntryErrOk) return(err); - *value=(uint16)m; + *value=(uint16_t)m; return(TIFFReadDirEntryErrOk); } case TIFF_LONG: { - uint32 m; + uint32_t m; TIFFReadDirEntryCheckedLong(tif,direntry,&m); err=TIFFReadDirEntryCheckRangeShortLong(m); if (err!=TIFFReadDirEntryErrOk) return(err); - *value=(uint16)m; + *value=(uint16_t)m; return(TIFFReadDirEntryErrOk); } case TIFF_SLONG: { - int32 m; + int32_t m; TIFFReadDirEntryCheckedSlong(tif,direntry,&m); err=TIFFReadDirEntryCheckRangeShortSlong(m); if (err!=TIFFReadDirEntryErrOk) return(err); - *value=(uint16)m; + *value=(uint16_t)m; return(TIFFReadDirEntryErrOk); } case TIFF_LONG8: { - uint64 m; + uint64_t m; err=TIFFReadDirEntryCheckedLong8(tif,direntry,&m); if (err!=TIFFReadDirEntryErrOk) return(err); err=TIFFReadDirEntryCheckRangeShortLong8(m); if (err!=TIFFReadDirEntryErrOk) return(err); - *value=(uint16)m; + *value=(uint16_t)m; return(TIFFReadDirEntryErrOk); } case TIFF_SLONG8: { - int64 m; + int64_t m; err=TIFFReadDirEntryCheckedSlong8(tif,direntry,&m); if (err!=TIFFReadDirEntryErrOk) return(err); err=TIFFReadDirEntryCheckRangeShortSlong8(m); if (err!=TIFFReadDirEntryErrOk) return(err); - *value=(uint16)m; + *value=(uint16_t)m; return(TIFFReadDirEntryErrOk); } default: @@ -375,7 +371,7 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryShort(TIFF* tif, TIFFDirEntry* d } } -static enum TIFFReadDirEntryErr TIFFReadDirEntryLong(TIFF* tif, TIFFDirEntry* direntry, uint32* value) +static enum TIFFReadDirEntryErr TIFFReadDirEntryLong(TIFF* tif, TIFFDirEntry* direntry, uint32_t* value) { enum TIFFReadDirEntryErr err; if (direntry->tdir_count!=1) @@ -384,36 +380,36 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryLong(TIFF* tif, TIFFDirEntry* di { case TIFF_BYTE: { - uint8 m; + uint8_t m; TIFFReadDirEntryCheckedByte(tif,direntry,&m); - *value=(uint32)m; + *value=(uint32_t)m; return(TIFFReadDirEntryErrOk); } case TIFF_SBYTE: { - int8 m; + int8_t m; TIFFReadDirEntryCheckedSbyte(tif,direntry,&m); err=TIFFReadDirEntryCheckRangeLongSbyte(m); if (err!=TIFFReadDirEntryErrOk) return(err); - *value=(uint32)m; + *value=(uint32_t)m; return(TIFFReadDirEntryErrOk); } case TIFF_SHORT: { - uint16 m; + uint16_t m; TIFFReadDirEntryCheckedShort(tif,direntry,&m); - *value=(uint32)m; + *value=(uint32_t)m; return(TIFFReadDirEntryErrOk); } case TIFF_SSHORT: { - int16 m; + int16_t m; TIFFReadDirEntryCheckedSshort(tif,direntry,&m); err=TIFFReadDirEntryCheckRangeLongSshort(m); if (err!=TIFFReadDirEntryErrOk) return(err); - *value=(uint32)m; + *value=(uint32_t)m; return(TIFFReadDirEntryErrOk); } case TIFF_LONG: @@ -421,36 +417,36 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryLong(TIFF* tif, TIFFDirEntry* di return(TIFFReadDirEntryErrOk); case TIFF_SLONG: { - int32 m; + int32_t m; TIFFReadDirEntryCheckedSlong(tif,direntry,&m); err=TIFFReadDirEntryCheckRangeLongSlong(m); if (err!=TIFFReadDirEntryErrOk) return(err); - *value=(uint32)m; + *value=(uint32_t)m; return(TIFFReadDirEntryErrOk); } case TIFF_LONG8: { - uint64 m; + uint64_t m; err=TIFFReadDirEntryCheckedLong8(tif,direntry,&m); if (err!=TIFFReadDirEntryErrOk) return(err); err=TIFFReadDirEntryCheckRangeLongLong8(m); if (err!=TIFFReadDirEntryErrOk) return(err); - *value=(uint32)m; + *value=(uint32_t)m; return(TIFFReadDirEntryErrOk); } case TIFF_SLONG8: { - int64 m; + int64_t m; err=TIFFReadDirEntryCheckedSlong8(tif,direntry,&m); if (err!=TIFFReadDirEntryErrOk) return(err); err=TIFFReadDirEntryCheckRangeLongSlong8(m); if (err!=TIFFReadDirEntryErrOk) return(err); - *value=(uint32)m; + *value=(uint32_t)m; return(TIFFReadDirEntryErrOk); } default: @@ -458,7 +454,7 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryLong(TIFF* tif, TIFFDirEntry* di } } -static enum TIFFReadDirEntryErr TIFFReadDirEntryLong8(TIFF* tif, TIFFDirEntry* direntry, uint64* value) +static enum TIFFReadDirEntryErr TIFFReadDirEntryLong8(TIFF* tif, TIFFDirEntry* direntry, uint64_t* value) { enum TIFFReadDirEntryErr err; if (direntry->tdir_count!=1) @@ -467,53 +463,53 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryLong8(TIFF* tif, TIFFDirEntry* d { case TIFF_BYTE: { - uint8 m; + uint8_t m; TIFFReadDirEntryCheckedByte(tif,direntry,&m); - *value=(uint64)m; + *value=(uint64_t)m; return(TIFFReadDirEntryErrOk); } case TIFF_SBYTE: { - int8 m; + int8_t m; TIFFReadDirEntryCheckedSbyte(tif,direntry,&m); err=TIFFReadDirEntryCheckRangeLong8Sbyte(m); if (err!=TIFFReadDirEntryErrOk) return(err); - *value=(uint64)m; + *value=(uint64_t)m; return(TIFFReadDirEntryErrOk); } case TIFF_SHORT: { - uint16 m; + uint16_t m; TIFFReadDirEntryCheckedShort(tif,direntry,&m); - *value=(uint64)m; + *value=(uint64_t)m; return(TIFFReadDirEntryErrOk); } case TIFF_SSHORT: { - int16 m; + int16_t m; TIFFReadDirEntryCheckedSshort(tif,direntry,&m); err=TIFFReadDirEntryCheckRangeLong8Sshort(m); if (err!=TIFFReadDirEntryErrOk) return(err); - *value=(uint64)m; + *value=(uint64_t)m; return(TIFFReadDirEntryErrOk); } case TIFF_LONG: { - uint32 m; + uint32_t m; TIFFReadDirEntryCheckedLong(tif,direntry,&m); - *value=(uint64)m; + *value=(uint64_t)m; return(TIFFReadDirEntryErrOk); } case TIFF_SLONG: { - int32 m; + int32_t m; TIFFReadDirEntryCheckedSlong(tif,direntry,&m); err=TIFFReadDirEntryCheckRangeLong8Slong(m); if (err!=TIFFReadDirEntryErrOk) return(err); - *value=(uint64)m; + *value=(uint64_t)m; return(TIFFReadDirEntryErrOk); } case TIFF_LONG8: @@ -521,14 +517,14 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryLong8(TIFF* tif, TIFFDirEntry* d return(err); case TIFF_SLONG8: { - int64 m; + int64_t m; err=TIFFReadDirEntryCheckedSlong8(tif,direntry,&m); if (err!=TIFFReadDirEntryErrOk) return(err); err=TIFFReadDirEntryCheckRangeLong8Slong8(m); if (err!=TIFFReadDirEntryErrOk) return(err); - *value=(uint64)m; + *value=(uint64_t)m; return(TIFFReadDirEntryErrOk); } default: @@ -545,49 +541,49 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryFloat(TIFF* tif, TIFFDirEntry* d { case TIFF_BYTE: { - uint8 m; + uint8_t m; TIFFReadDirEntryCheckedByte(tif,direntry,&m); *value=(float)m; return(TIFFReadDirEntryErrOk); } case TIFF_SBYTE: { - int8 m; + int8_t m; TIFFReadDirEntryCheckedSbyte(tif,direntry,&m); *value=(float)m; return(TIFFReadDirEntryErrOk); } case TIFF_SHORT: { - uint16 m; + uint16_t m; TIFFReadDirEntryCheckedShort(tif,direntry,&m); *value=(float)m; return(TIFFReadDirEntryErrOk); } case TIFF_SSHORT: { - int16 m; + int16_t m; TIFFReadDirEntryCheckedSshort(tif,direntry,&m); *value=(float)m; return(TIFFReadDirEntryErrOk); } case TIFF_LONG: { - uint32 m; + uint32_t m; TIFFReadDirEntryCheckedLong(tif,direntry,&m); *value=(float)m; return(TIFFReadDirEntryErrOk); } case TIFF_SLONG: { - int32 m; + int32_t m; TIFFReadDirEntryCheckedSlong(tif,direntry,&m); *value=(float)m; return(TIFFReadDirEntryErrOk); } case TIFF_LONG8: { - uint64 m; + uint64_t m; err=TIFFReadDirEntryCheckedLong8(tif,direntry,&m); if (err!=TIFFReadDirEntryErrOk) return(err); @@ -605,7 +601,7 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryFloat(TIFF* tif, TIFFDirEntry* d } case TIFF_SLONG8: { - int64 m; + int64_t m; err=TIFFReadDirEntryCheckedSlong8(tif,direntry,&m); if (err!=TIFFReadDirEntryErrOk) return(err); @@ -658,49 +654,49 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryDouble(TIFF* tif, TIFFDirEntry* { case TIFF_BYTE: { - uint8 m; + uint8_t m; TIFFReadDirEntryCheckedByte(tif,direntry,&m); *value=(double)m; return(TIFFReadDirEntryErrOk); } case TIFF_SBYTE: { - int8 m; + int8_t m; TIFFReadDirEntryCheckedSbyte(tif,direntry,&m); *value=(double)m; return(TIFFReadDirEntryErrOk); } case TIFF_SHORT: { - uint16 m; + uint16_t m; TIFFReadDirEntryCheckedShort(tif,direntry,&m); *value=(double)m; return(TIFFReadDirEntryErrOk); } case TIFF_SSHORT: { - int16 m; + int16_t m; TIFFReadDirEntryCheckedSshort(tif,direntry,&m); *value=(double)m; return(TIFFReadDirEntryErrOk); } case TIFF_LONG: { - uint32 m; + uint32_t m; TIFFReadDirEntryCheckedLong(tif,direntry,&m); *value=(double)m; return(TIFFReadDirEntryErrOk); } case TIFF_SLONG: { - int32 m; + int32_t m; TIFFReadDirEntryCheckedSlong(tif,direntry,&m); *value=(double)m; return(TIFFReadDirEntryErrOk); } case TIFF_LONG8: { - uint64 m; + uint64_t m; err=TIFFReadDirEntryCheckedLong8(tif,direntry,&m); if (err!=TIFFReadDirEntryErrOk) return(err); @@ -718,7 +714,7 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryDouble(TIFF* tif, TIFFDirEntry* } case TIFF_SLONG8: { - int64 m; + int64_t m; err=TIFFReadDirEntryCheckedSlong8(tif,direntry,&m); if (err!=TIFFReadDirEntryErrOk) return(err); @@ -746,7 +742,7 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryDouble(TIFF* tif, TIFFDirEntry* } } -static enum TIFFReadDirEntryErr TIFFReadDirEntryIfd8(TIFF* tif, TIFFDirEntry* direntry, uint64* value) +static enum TIFFReadDirEntryErr TIFFReadDirEntryIfd8(TIFF* tif, TIFFDirEntry* direntry, uint64_t* value) { enum TIFFReadDirEntryErr err; if (direntry->tdir_count!=1) @@ -756,9 +752,9 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryIfd8(TIFF* tif, TIFFDirEntry* di case TIFF_LONG: case TIFF_IFD: { - uint32 m; + uint32_t m; TIFFReadDirEntryCheckedLong(tif,direntry,&m); - *value=(uint64)m; + *value=(uint64_t)m; return(TIFFReadDirEntryErrOk); } case TIFF_LONG8: @@ -776,7 +772,7 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryIfd8(TIFF* tif, TIFFDirEntry* di #define MAX_THRESHOLD (THRESHOLD_MULTIPLIER * THRESHOLD_MULTIPLIER * THRESHOLD_MULTIPLIER * INITIAL_THRESHOLD) static enum TIFFReadDirEntryErr TIFFReadDirEntryDataAndRealloc( - TIFF* tif, uint64 offset, tmsize_t size, void** pdest) + TIFF* tif, uint64_t offset, tmsize_t size, void** pdest) { #if SIZEOF_SIZE_T == 8 tmsize_t threshold = INITIAL_THRESHOLD; @@ -807,15 +803,15 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryDataAndRealloc( } #endif - new_dest = (uint8*) _TIFFrealloc( + new_dest = (uint8_t*) _TIFFrealloc( *pdest, already_read + to_read); if( new_dest == NULL ) { TIFFErrorExt(tif->tif_clientdata, tif->tif_name, "Failed to allocate memory for %s " - "(%ld elements of %ld bytes each)", + "(%"TIFF_SSIZE_FORMAT" elements of %"TIFF_SSIZE_FORMAT" bytes each)", "TIFFReadDirEntryArray", - (long) 1, (long) (already_read + to_read)); + (tmsize_t) 1, already_read + to_read); return TIFFReadDirEntryErrAlloc; } *pdest = new_dest; @@ -831,13 +827,13 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryDataAndRealloc( } static enum TIFFReadDirEntryErr TIFFReadDirEntryArrayWithLimit( - TIFF* tif, TIFFDirEntry* direntry, uint32* count, uint32 desttypesize, - void** value, uint64 maxcount) + TIFF* tif, TIFFDirEntry* direntry, uint32_t* count, uint32_t desttypesize, + void** value, uint64_t maxcount) { int typesize; - uint32 datasize; + uint32_t datasize; void* data; - uint64 target_count64; + uint64_t target_count64; int original_datasize_clamped; typesize=TIFFDataWidth(direntry->tdir_type); @@ -862,16 +858,16 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryArrayWithLimit( * in either the current data type or the dest data type. This also * avoids problems with overflow of tmsize_t on 32bit systems. */ - if ((uint64)(2147483647/typesize)<target_count64) + if ((uint64_t)(2147483647 / typesize) < target_count64) return(TIFFReadDirEntryErrSizesan); - if ((uint64)(2147483647/desttypesize)<target_count64) + if ((uint64_t)(2147483647 / desttypesize) < target_count64) return(TIFFReadDirEntryErrSizesan); - *count=(uint32)target_count64; + *count=(uint32_t)target_count64; datasize=(*count)*typesize; assert((tmsize_t)datasize>0); - if( isMapped(tif) && datasize > (uint64)tif->tif_size ) + if( isMapped(tif) && datasize > (uint64_t)tif->tif_size ) return TIFFReadDirEntryErrIo; if( !isMapped(tif) && @@ -888,18 +884,20 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryArrayWithLimit( } if (!(tif->tif_flags&TIFF_BIGTIFF)) { - if (original_datasize_clamped<=4) + /* Only the condition on original_datasize_clamped. The second + * one is implied, but Coverity Scan cannot see it. */ + if (original_datasize_clamped<=4 && datasize <= 4 ) _TIFFmemcpy(data,&direntry->tdir_offset,datasize); else { enum TIFFReadDirEntryErr err; - uint32 offset = direntry->tdir_offset.toff_long; + uint32_t offset = direntry->tdir_offset.toff_long; if (tif->tif_flags&TIFF_SWAB) TIFFSwabLong(&offset); if( isMapped(tif) ) - err=TIFFReadDirEntryData(tif,(uint64)offset,(tmsize_t)datasize,data); + err=TIFFReadDirEntryData(tif, (uint64_t)offset, (tmsize_t)datasize, data); else - err=TIFFReadDirEntryDataAndRealloc(tif,(uint64)offset,(tmsize_t)datasize,&data); + err=TIFFReadDirEntryDataAndRealloc(tif, (uint64_t)offset, (tmsize_t)datasize, &data); if (err!=TIFFReadDirEntryErrOk) { _TIFFfree(data); @@ -909,18 +907,19 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryArrayWithLimit( } else { - if (original_datasize_clamped<=8) + /* See above comment for the Classic TIFF case */ + if (original_datasize_clamped<=8 && datasize <= 8 ) _TIFFmemcpy(data,&direntry->tdir_offset,datasize); else { enum TIFFReadDirEntryErr err; - uint64 offset = direntry->tdir_offset.toff_long8; + uint64_t offset = direntry->tdir_offset.toff_long8; if (tif->tif_flags&TIFF_SWAB) TIFFSwabLong8(&offset); if( isMapped(tif) ) - err=TIFFReadDirEntryData(tif,(uint64)offset,(tmsize_t)datasize,data); + err=TIFFReadDirEntryData(tif, (uint64_t)offset, (tmsize_t)datasize, data); else - err=TIFFReadDirEntryDataAndRealloc(tif,(uint64)offset,(tmsize_t)datasize,&data); + err=TIFFReadDirEntryDataAndRealloc(tif, (uint64_t)offset, (tmsize_t)datasize, &data); if (err!=TIFFReadDirEntryErrOk) { _TIFFfree(data); @@ -932,18 +931,18 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryArrayWithLimit( return(TIFFReadDirEntryErrOk); } -static enum TIFFReadDirEntryErr TIFFReadDirEntryArray(TIFF* tif, TIFFDirEntry* direntry, uint32* count, uint32 desttypesize, void** value) +static enum TIFFReadDirEntryErr TIFFReadDirEntryArray(TIFF* tif, TIFFDirEntry* direntry, uint32_t* count, uint32_t desttypesize, void** value) { return TIFFReadDirEntryArrayWithLimit(tif, direntry, count, - desttypesize, value, ~((uint64)0)); + desttypesize, value, ~((uint64_t)0)); } -static enum TIFFReadDirEntryErr TIFFReadDirEntryByteArray(TIFF* tif, TIFFDirEntry* direntry, uint8** value) +static enum TIFFReadDirEntryErr TIFFReadDirEntryByteArray(TIFF* tif, TIFFDirEntry* direntry, uint8_t** value) { enum TIFFReadDirEntryErr err; - uint32 count; + uint32_t count; void* origdata; - uint8* data; + uint8_t* data; switch (direntry->tdir_type) { case TIFF_ASCII: @@ -971,13 +970,13 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryByteArray(TIFF* tif, TIFFDirEntr case TIFF_ASCII: case TIFF_UNDEFINED: case TIFF_BYTE: - *value=(uint8*)origdata; + *value=(uint8_t*)origdata; return(TIFFReadDirEntryErrOk); case TIFF_SBYTE: { - int8* m; - uint32 n; - m=(int8*)origdata; + int8_t* m; + uint32_t n; + m=(int8_t*)origdata; for (n=0; n<count; n++) { err=TIFFReadDirEntryCheckRangeByteSbyte(*m); @@ -988,11 +987,11 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryByteArray(TIFF* tif, TIFFDirEntr } m++; } - *value=(uint8*)origdata; + *value=(uint8_t*)origdata; return(TIFFReadDirEntryErrOk); } } - data=(uint8*)_TIFFmalloc(count); + data=(uint8_t*)_TIFFmalloc(count); if (data==0) { _TIFFfree(origdata); @@ -1002,10 +1001,10 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryByteArray(TIFF* tif, TIFFDirEntr { case TIFF_SHORT: { - uint16* ma; - uint8* mb; - uint32 n; - ma=(uint16*)origdata; + uint16_t* ma; + uint8_t* mb; + uint32_t n; + ma=(uint16_t*)origdata; mb=data; for (n=0; n<count; n++) { @@ -1014,34 +1013,34 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryByteArray(TIFF* tif, TIFFDirEntr err=TIFFReadDirEntryCheckRangeByteShort(*ma); if (err!=TIFFReadDirEntryErrOk) break; - *mb++=(uint8)(*ma++); + *mb++=(uint8_t)(*ma++); } } break; case TIFF_SSHORT: { - int16* ma; - uint8* mb; - uint32 n; - ma=(int16*)origdata; + int16_t* ma; + uint8_t* mb; + uint32_t n; + ma=(int16_t*)origdata; mb=data; for (n=0; n<count; n++) { if (tif->tif_flags&TIFF_SWAB) - TIFFSwabShort((uint16*)ma); + TIFFSwabShort((uint16_t*)ma); err=TIFFReadDirEntryCheckRangeByteSshort(*ma); if (err!=TIFFReadDirEntryErrOk) break; - *mb++=(uint8)(*ma++); + *mb++=(uint8_t)(*ma++); } } break; case TIFF_LONG: { - uint32* ma; - uint8* mb; - uint32 n; - ma=(uint32*)origdata; + uint32_t* ma; + uint8_t* mb; + uint32_t n; + ma=(uint32_t*)origdata; mb=data; for (n=0; n<count; n++) { @@ -1050,34 +1049,34 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryByteArray(TIFF* tif, TIFFDirEntr err=TIFFReadDirEntryCheckRangeByteLong(*ma); if (err!=TIFFReadDirEntryErrOk) break; - *mb++=(uint8)(*ma++); + *mb++=(uint8_t)(*ma++); } } break; case TIFF_SLONG: { - int32* ma; - uint8* mb; - uint32 n; - ma=(int32*)origdata; + int32_t* ma; + uint8_t* mb; + uint32_t n; + ma=(int32_t*)origdata; mb=data; for (n=0; n<count; n++) { if (tif->tif_flags&TIFF_SWAB) - TIFFSwabLong((uint32*)ma); + TIFFSwabLong((uint32_t*)ma); err=TIFFReadDirEntryCheckRangeByteSlong(*ma); if (err!=TIFFReadDirEntryErrOk) break; - *mb++=(uint8)(*ma++); + *mb++=(uint8_t)(*ma++); } } break; case TIFF_LONG8: { - uint64* ma; - uint8* mb; - uint32 n; - ma=(uint64*)origdata; + uint64_t* ma; + uint8_t* mb; + uint32_t n; + ma=(uint64_t*)origdata; mb=data; for (n=0; n<count; n++) { @@ -1086,25 +1085,25 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryByteArray(TIFF* tif, TIFFDirEntr err=TIFFReadDirEntryCheckRangeByteLong8(*ma); if (err!=TIFFReadDirEntryErrOk) break; - *mb++=(uint8)(*ma++); + *mb++=(uint8_t)(*ma++); } } break; case TIFF_SLONG8: { - int64* ma; - uint8* mb; - uint32 n; - ma=(int64*)origdata; + int64_t* ma; + uint8_t* mb; + uint32_t n; + ma=(int64_t*)origdata; mb=data; for (n=0; n<count; n++) { if (tif->tif_flags&TIFF_SWAB) - TIFFSwabLong8((uint64*)ma); + TIFFSwabLong8((uint64_t*)ma); err=TIFFReadDirEntryCheckRangeByteSlong8(*ma); if (err!=TIFFReadDirEntryErrOk) break; - *mb++=(uint8)(*ma++); + *mb++=(uint8_t)(*ma++); } } break; @@ -1119,12 +1118,12 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryByteArray(TIFF* tif, TIFFDirEntr return(TIFFReadDirEntryErrOk); } -static enum TIFFReadDirEntryErr TIFFReadDirEntrySbyteArray(TIFF* tif, TIFFDirEntry* direntry, int8** value) +static enum TIFFReadDirEntryErr TIFFReadDirEntrySbyteArray(TIFF* tif, TIFFDirEntry* direntry, int8_t** value) { enum TIFFReadDirEntryErr err; - uint32 count; + uint32_t count; void* origdata; - int8* data; + int8_t* data; switch (direntry->tdir_type) { case TIFF_UNDEFINED: @@ -1151,9 +1150,9 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntrySbyteArray(TIFF* tif, TIFFDirEnt case TIFF_UNDEFINED: case TIFF_BYTE: { - uint8* m; - uint32 n; - m=(uint8*)origdata; + uint8_t* m; + uint32_t n; + m=(uint8_t*)origdata; for (n=0; n<count; n++) { err=TIFFReadDirEntryCheckRangeSbyteByte(*m); @@ -1164,14 +1163,14 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntrySbyteArray(TIFF* tif, TIFFDirEnt } m++; } - *value=(int8*)origdata; + *value=(int8_t*)origdata; return(TIFFReadDirEntryErrOk); } case TIFF_SBYTE: - *value=(int8*)origdata; + *value=(int8_t*)origdata; return(TIFFReadDirEntryErrOk); } - data=(int8*)_TIFFmalloc(count); + data=(int8_t*)_TIFFmalloc(count); if (data==0) { _TIFFfree(origdata); @@ -1181,10 +1180,10 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntrySbyteArray(TIFF* tif, TIFFDirEnt { case TIFF_SHORT: { - uint16* ma; - int8* mb; - uint32 n; - ma=(uint16*)origdata; + uint16_t* ma; + int8_t* mb; + uint32_t n; + ma=(uint16_t*)origdata; mb=data; for (n=0; n<count; n++) { @@ -1193,34 +1192,34 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntrySbyteArray(TIFF* tif, TIFFDirEnt err=TIFFReadDirEntryCheckRangeSbyteShort(*ma); if (err!=TIFFReadDirEntryErrOk) break; - *mb++=(int8)(*ma++); + *mb++=(int8_t)(*ma++); } } break; case TIFF_SSHORT: { - int16* ma; - int8* mb; - uint32 n; - ma=(int16*)origdata; + int16_t* ma; + int8_t* mb; + uint32_t n; + ma=(int16_t*)origdata; mb=data; for (n=0; n<count; n++) { if (tif->tif_flags&TIFF_SWAB) - TIFFSwabShort((uint16*)ma); + TIFFSwabShort((uint16_t*)ma); err=TIFFReadDirEntryCheckRangeSbyteSshort(*ma); if (err!=TIFFReadDirEntryErrOk) break; - *mb++=(int8)(*ma++); + *mb++=(int8_t)(*ma++); } } break; case TIFF_LONG: { - uint32* ma; - int8* mb; - uint32 n; - ma=(uint32*)origdata; + uint32_t* ma; + int8_t* mb; + uint32_t n; + ma=(uint32_t*)origdata; mb=data; for (n=0; n<count; n++) { @@ -1229,34 +1228,34 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntrySbyteArray(TIFF* tif, TIFFDirEnt err=TIFFReadDirEntryCheckRangeSbyteLong(*ma); if (err!=TIFFReadDirEntryErrOk) break; - *mb++=(int8)(*ma++); + *mb++=(int8_t)(*ma++); } } break; case TIFF_SLONG: { - int32* ma; - int8* mb; - uint32 n; - ma=(int32*)origdata; + int32_t* ma; + int8_t* mb; + uint32_t n; + ma=(int32_t*)origdata; mb=data; for (n=0; n<count; n++) { if (tif->tif_flags&TIFF_SWAB) - TIFFSwabLong((uint32*)ma); + TIFFSwabLong((uint32_t*)ma); err=TIFFReadDirEntryCheckRangeSbyteSlong(*ma); if (err!=TIFFReadDirEntryErrOk) break; - *mb++=(int8)(*ma++); + *mb++=(int8_t)(*ma++); } } break; case TIFF_LONG8: { - uint64* ma; - int8* mb; - uint32 n; - ma=(uint64*)origdata; + uint64_t* ma; + int8_t* mb; + uint32_t n; + ma=(uint64_t*)origdata; mb=data; for (n=0; n<count; n++) { @@ -1265,25 +1264,25 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntrySbyteArray(TIFF* tif, TIFFDirEnt err=TIFFReadDirEntryCheckRangeSbyteLong8(*ma); if (err!=TIFFReadDirEntryErrOk) break; - *mb++=(int8)(*ma++); + *mb++=(int8_t)(*ma++); } } break; case TIFF_SLONG8: { - int64* ma; - int8* mb; - uint32 n; - ma=(int64*)origdata; + int64_t* ma; + int8_t* mb; + uint32_t n; + ma=(int64_t*)origdata; mb=data; for (n=0; n<count; n++) { if (tif->tif_flags&TIFF_SWAB) - TIFFSwabLong8((uint64*)ma); + TIFFSwabLong8((uint64_t*)ma); err=TIFFReadDirEntryCheckRangeSbyteSlong8(*ma); if (err!=TIFFReadDirEntryErrOk) break; - *mb++=(int8)(*ma++); + *mb++=(int8_t)(*ma++); } } break; @@ -1298,12 +1297,12 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntrySbyteArray(TIFF* tif, TIFFDirEnt return(TIFFReadDirEntryErrOk); } -static enum TIFFReadDirEntryErr TIFFReadDirEntryShortArray(TIFF* tif, TIFFDirEntry* direntry, uint16** value) +static enum TIFFReadDirEntryErr TIFFReadDirEntryShortArray(TIFF* tif, TIFFDirEntry* direntry, uint16_t** value) { enum TIFFReadDirEntryErr err; - uint32 count; + uint32_t count; void* origdata; - uint16* data; + uint16_t* data; switch (direntry->tdir_type) { case TIFF_BYTE: @@ -1327,19 +1326,19 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryShortArray(TIFF* tif, TIFFDirEnt switch (direntry->tdir_type) { case TIFF_SHORT: - *value=(uint16*)origdata; + *value=(uint16_t*)origdata; if (tif->tif_flags&TIFF_SWAB) TIFFSwabArrayOfShort(*value,count); return(TIFFReadDirEntryErrOk); case TIFF_SSHORT: { - int16* m; - uint32 n; - m=(int16*)origdata; + int16_t* m; + uint32_t n; + m=(int16_t*)origdata; for (n=0; n<count; n++) { if (tif->tif_flags&TIFF_SWAB) - TIFFSwabShort((uint16*)m); + TIFFSwabShort((uint16_t*)m); err=TIFFReadDirEntryCheckRangeShortSshort(*m); if (err!=TIFFReadDirEntryErrOk) { @@ -1348,11 +1347,11 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryShortArray(TIFF* tif, TIFFDirEnt } m++; } - *value=(uint16*)origdata; + *value=(uint16_t*)origdata; return(TIFFReadDirEntryErrOk); } } - data=(uint16*)_TIFFmalloc(count*2); + data=(uint16_t*)_TIFFmalloc(count * 2); if (data==0) { _TIFFfree(origdata); @@ -1362,37 +1361,37 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryShortArray(TIFF* tif, TIFFDirEnt { case TIFF_BYTE: { - uint8* ma; - uint16* mb; - uint32 n; - ma=(uint8*)origdata; + uint8_t* ma; + uint16_t* mb; + uint32_t n; + ma=(uint8_t*)origdata; mb=data; for (n=0; n<count; n++) - *mb++=(uint16)(*ma++); + *mb++=(uint16_t)(*ma++); } break; case TIFF_SBYTE: { - int8* ma; - uint16* mb; - uint32 n; - ma=(int8*)origdata; + int8_t* ma; + uint16_t* mb; + uint32_t n; + ma=(int8_t*)origdata; mb=data; for (n=0; n<count; n++) { err=TIFFReadDirEntryCheckRangeShortSbyte(*ma); if (err!=TIFFReadDirEntryErrOk) break; - *mb++=(uint16)(*ma++); + *mb++=(uint16_t)(*ma++); } } break; case TIFF_LONG: { - uint32* ma; - uint16* mb; - uint32 n; - ma=(uint32*)origdata; + uint32_t* ma; + uint16_t* mb; + uint32_t n; + ma=(uint32_t*)origdata; mb=data; for (n=0; n<count; n++) { @@ -1401,34 +1400,34 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryShortArray(TIFF* tif, TIFFDirEnt err=TIFFReadDirEntryCheckRangeShortLong(*ma); if (err!=TIFFReadDirEntryErrOk) break; - *mb++=(uint16)(*ma++); + *mb++=(uint16_t)(*ma++); } } break; case TIFF_SLONG: { - int32* ma; - uint16* mb; - uint32 n; - ma=(int32*)origdata; + int32_t* ma; + uint16_t* mb; + uint32_t n; + ma=(int32_t*)origdata; mb=data; for (n=0; n<count; n++) { if (tif->tif_flags&TIFF_SWAB) - TIFFSwabLong((uint32*)ma); + TIFFSwabLong((uint32_t*)ma); err=TIFFReadDirEntryCheckRangeShortSlong(*ma); if (err!=TIFFReadDirEntryErrOk) break; - *mb++=(uint16)(*ma++); + *mb++=(uint16_t)(*ma++); } } break; case TIFF_LONG8: { - uint64* ma; - uint16* mb; - uint32 n; - ma=(uint64*)origdata; + uint64_t* ma; + uint16_t* mb; + uint32_t n; + ma=(uint64_t*)origdata; mb=data; for (n=0; n<count; n++) { @@ -1437,25 +1436,25 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryShortArray(TIFF* tif, TIFFDirEnt err=TIFFReadDirEntryCheckRangeShortLong8(*ma); if (err!=TIFFReadDirEntryErrOk) break; - *mb++=(uint16)(*ma++); + *mb++=(uint16_t)(*ma++); } } break; case TIFF_SLONG8: { - int64* ma; - uint16* mb; - uint32 n; - ma=(int64*)origdata; + int64_t* ma; + uint16_t* mb; + uint32_t n; + ma=(int64_t*)origdata; mb=data; for (n=0; n<count; n++) { if (tif->tif_flags&TIFF_SWAB) - TIFFSwabLong8((uint64*)ma); + TIFFSwabLong8((uint64_t*)ma); err=TIFFReadDirEntryCheckRangeShortSlong8(*ma); if (err!=TIFFReadDirEntryErrOk) break; - *mb++=(uint16)(*ma++); + *mb++=(uint16_t)(*ma++); } } break; @@ -1470,12 +1469,12 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryShortArray(TIFF* tif, TIFFDirEnt return(TIFFReadDirEntryErrOk); } -static enum TIFFReadDirEntryErr TIFFReadDirEntrySshortArray(TIFF* tif, TIFFDirEntry* direntry, int16** value) +static enum TIFFReadDirEntryErr TIFFReadDirEntrySshortArray(TIFF* tif, TIFFDirEntry* direntry, int16_t** value) { enum TIFFReadDirEntryErr err; - uint32 count; + uint32_t count; void* origdata; - int16* data; + int16_t* data; switch (direntry->tdir_type) { case TIFF_BYTE: @@ -1500,9 +1499,9 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntrySshortArray(TIFF* tif, TIFFDirEn { case TIFF_SHORT: { - uint16* m; - uint32 n; - m=(uint16*)origdata; + uint16_t* m; + uint32_t n; + m=(uint16_t*)origdata; for (n=0; n<count; n++) { if (tif->tif_flags&TIFF_SWAB) @@ -1515,16 +1514,16 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntrySshortArray(TIFF* tif, TIFFDirEn } m++; } - *value=(int16*)origdata; + *value=(int16_t*)origdata; return(TIFFReadDirEntryErrOk); } case TIFF_SSHORT: - *value=(int16*)origdata; + *value=(int16_t*)origdata; if (tif->tif_flags&TIFF_SWAB) - TIFFSwabArrayOfShort((uint16*)(*value),count); + TIFFSwabArrayOfShort((uint16_t*)(*value), count); return(TIFFReadDirEntryErrOk); } - data=(int16*)_TIFFmalloc(count*2); + data=(int16_t*)_TIFFmalloc(count * 2); if (data==0) { _TIFFfree(origdata); @@ -1534,32 +1533,32 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntrySshortArray(TIFF* tif, TIFFDirEn { case TIFF_BYTE: { - uint8* ma; - int16* mb; - uint32 n; - ma=(uint8*)origdata; + uint8_t* ma; + int16_t* mb; + uint32_t n; + ma=(uint8_t*)origdata; mb=data; for (n=0; n<count; n++) - *mb++=(int16)(*ma++); + *mb++=(int16_t)(*ma++); } break; case TIFF_SBYTE: { - int8* ma; - int16* mb; - uint32 n; - ma=(int8*)origdata; + int8_t* ma; + int16_t* mb; + uint32_t n; + ma=(int8_t*)origdata; mb=data; for (n=0; n<count; n++) - *mb++=(int16)(*ma++); + *mb++=(int16_t)(*ma++); } break; case TIFF_LONG: { - uint32* ma; - int16* mb; - uint32 n; - ma=(uint32*)origdata; + uint32_t* ma; + int16_t* mb; + uint32_t n; + ma=(uint32_t*)origdata; mb=data; for (n=0; n<count; n++) { @@ -1568,34 +1567,34 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntrySshortArray(TIFF* tif, TIFFDirEn err=TIFFReadDirEntryCheckRangeSshortLong(*ma); if (err!=TIFFReadDirEntryErrOk) break; - *mb++=(int16)(*ma++); + *mb++=(int16_t)(*ma++); } } break; case TIFF_SLONG: { - int32* ma; - int16* mb; - uint32 n; - ma=(int32*)origdata; + int32_t* ma; + int16_t* mb; + uint32_t n; + ma=(int32_t*)origdata; mb=data; for (n=0; n<count; n++) { if (tif->tif_flags&TIFF_SWAB) - TIFFSwabLong((uint32*)ma); + TIFFSwabLong((uint32_t*)ma); err=TIFFReadDirEntryCheckRangeSshortSlong(*ma); if (err!=TIFFReadDirEntryErrOk) break; - *mb++=(int16)(*ma++); + *mb++=(int16_t)(*ma++); } } break; case TIFF_LONG8: { - uint64* ma; - int16* mb; - uint32 n; - ma=(uint64*)origdata; + uint64_t* ma; + int16_t* mb; + uint32_t n; + ma=(uint64_t*)origdata; mb=data; for (n=0; n<count; n++) { @@ -1604,25 +1603,25 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntrySshortArray(TIFF* tif, TIFFDirEn err=TIFFReadDirEntryCheckRangeSshortLong8(*ma); if (err!=TIFFReadDirEntryErrOk) break; - *mb++=(int16)(*ma++); + *mb++=(int16_t)(*ma++); } } break; case TIFF_SLONG8: { - int64* ma; - int16* mb; - uint32 n; - ma=(int64*)origdata; + int64_t* ma; + int16_t* mb; + uint32_t n; + ma=(int64_t*)origdata; mb=data; for (n=0; n<count; n++) { if (tif->tif_flags&TIFF_SWAB) - TIFFSwabLong8((uint64*)ma); + TIFFSwabLong8((uint64_t*)ma); err=TIFFReadDirEntryCheckRangeSshortSlong8(*ma); if (err!=TIFFReadDirEntryErrOk) break; - *mb++=(int16)(*ma++); + *mb++=(int16_t)(*ma++); } } break; @@ -1637,12 +1636,12 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntrySshortArray(TIFF* tif, TIFFDirEn return(TIFFReadDirEntryErrOk); } -static enum TIFFReadDirEntryErr TIFFReadDirEntryLongArray(TIFF* tif, TIFFDirEntry* direntry, uint32** value) +static enum TIFFReadDirEntryErr TIFFReadDirEntryLongArray(TIFF* tif, TIFFDirEntry* direntry, uint32_t** value) { enum TIFFReadDirEntryErr err; - uint32 count; + uint32_t count; void* origdata; - uint32* data; + uint32_t* data; switch (direntry->tdir_type) { case TIFF_BYTE: @@ -1666,19 +1665,19 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryLongArray(TIFF* tif, TIFFDirEntr switch (direntry->tdir_type) { case TIFF_LONG: - *value=(uint32*)origdata; + *value=(uint32_t*)origdata; if (tif->tif_flags&TIFF_SWAB) TIFFSwabArrayOfLong(*value,count); return(TIFFReadDirEntryErrOk); case TIFF_SLONG: { - int32* m; - uint32 n; - m=(int32*)origdata; + int32_t* m; + uint32_t n; + m=(int32_t*)origdata; for (n=0; n<count; n++) { if (tif->tif_flags&TIFF_SWAB) - TIFFSwabLong((uint32*)m); + TIFFSwabLong((uint32_t*)m); err=TIFFReadDirEntryCheckRangeLongSlong(*m); if (err!=TIFFReadDirEntryErrOk) { @@ -1687,11 +1686,11 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryLongArray(TIFF* tif, TIFFDirEntr } m++; } - *value=(uint32*)origdata; + *value=(uint32_t*)origdata; return(TIFFReadDirEntryErrOk); } } - data=(uint32*)_TIFFmalloc(count*4); + data=(uint32_t*)_TIFFmalloc(count * 4); if (data==0) { _TIFFfree(origdata); @@ -1701,70 +1700,70 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryLongArray(TIFF* tif, TIFFDirEntr { case TIFF_BYTE: { - uint8* ma; - uint32* mb; - uint32 n; - ma=(uint8*)origdata; + uint8_t* ma; + uint32_t* mb; + uint32_t n; + ma=(uint8_t*)origdata; mb=data; for (n=0; n<count; n++) - *mb++=(uint32)(*ma++); + *mb++=(uint32_t)(*ma++); } break; case TIFF_SBYTE: { - int8* ma; - uint32* mb; - uint32 n; - ma=(int8*)origdata; + int8_t* ma; + uint32_t* mb; + uint32_t n; + ma=(int8_t*)origdata; mb=data; for (n=0; n<count; n++) { err=TIFFReadDirEntryCheckRangeLongSbyte(*ma); if (err!=TIFFReadDirEntryErrOk) break; - *mb++=(uint32)(*ma++); + *mb++=(uint32_t)(*ma++); } } break; case TIFF_SHORT: { - uint16* ma; - uint32* mb; - uint32 n; - ma=(uint16*)origdata; + uint16_t* ma; + uint32_t* mb; + uint32_t n; + ma=(uint16_t*)origdata; mb=data; for (n=0; n<count; n++) { if (tif->tif_flags&TIFF_SWAB) TIFFSwabShort(ma); - *mb++=(uint32)(*ma++); + *mb++=(uint32_t)(*ma++); } } break; case TIFF_SSHORT: { - int16* ma; - uint32* mb; - uint32 n; - ma=(int16*)origdata; + int16_t* ma; + uint32_t* mb; + uint32_t n; + ma=(int16_t*)origdata; mb=data; for (n=0; n<count; n++) { if (tif->tif_flags&TIFF_SWAB) - TIFFSwabShort((uint16*)ma); + TIFFSwabShort((uint16_t*)ma); err=TIFFReadDirEntryCheckRangeLongSshort(*ma); if (err!=TIFFReadDirEntryErrOk) break; - *mb++=(uint32)(*ma++); + *mb++=(uint32_t)(*ma++); } } break; case TIFF_LONG8: { - uint64* ma; - uint32* mb; - uint32 n; - ma=(uint64*)origdata; + uint64_t* ma; + uint32_t* mb; + uint32_t n; + ma=(uint64_t*)origdata; mb=data; for (n=0; n<count; n++) { @@ -1773,25 +1772,25 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryLongArray(TIFF* tif, TIFFDirEntr err=TIFFReadDirEntryCheckRangeLongLong8(*ma); if (err!=TIFFReadDirEntryErrOk) break; - *mb++=(uint32)(*ma++); + *mb++=(uint32_t)(*ma++); } } break; case TIFF_SLONG8: { - int64* ma; - uint32* mb; - uint32 n; - ma=(int64*)origdata; + int64_t* ma; + uint32_t* mb; + uint32_t n; + ma=(int64_t*)origdata; mb=data; for (n=0; n<count; n++) { if (tif->tif_flags&TIFF_SWAB) - TIFFSwabLong8((uint64*)ma); + TIFFSwabLong8((uint64_t*)ma); err=TIFFReadDirEntryCheckRangeLongSlong8(*ma); if (err!=TIFFReadDirEntryErrOk) break; - *mb++=(uint32)(*ma++); + *mb++=(uint32_t)(*ma++); } } break; @@ -1806,12 +1805,12 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryLongArray(TIFF* tif, TIFFDirEntr return(TIFFReadDirEntryErrOk); } -static enum TIFFReadDirEntryErr TIFFReadDirEntrySlongArray(TIFF* tif, TIFFDirEntry* direntry, int32** value) +static enum TIFFReadDirEntryErr TIFFReadDirEntrySlongArray(TIFF* tif, TIFFDirEntry* direntry, int32_t** value) { enum TIFFReadDirEntryErr err; - uint32 count; + uint32_t count; void* origdata; - int32* data; + int32_t* data; switch (direntry->tdir_type) { case TIFF_BYTE: @@ -1836,13 +1835,13 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntrySlongArray(TIFF* tif, TIFFDirEnt { case TIFF_LONG: { - uint32* m; - uint32 n; - m=(uint32*)origdata; + uint32_t* m; + uint32_t n; + m=(uint32_t*)origdata; for (n=0; n<count; n++) { if (tif->tif_flags&TIFF_SWAB) - TIFFSwabLong((uint32*)m); + TIFFSwabLong((uint32_t*)m); err=TIFFReadDirEntryCheckRangeSlongLong(*m); if (err!=TIFFReadDirEntryErrOk) { @@ -1851,16 +1850,16 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntrySlongArray(TIFF* tif, TIFFDirEnt } m++; } - *value=(int32*)origdata; + *value=(int32_t*)origdata; return(TIFFReadDirEntryErrOk); } case TIFF_SLONG: - *value=(int32*)origdata; + *value=(int32_t*)origdata; if (tif->tif_flags&TIFF_SWAB) - TIFFSwabArrayOfLong((uint32*)(*value),count); + TIFFSwabArrayOfLong((uint32_t*)(*value), count); return(TIFFReadDirEntryErrOk); } - data=(int32*)_TIFFmalloc(count*4); + data=(int32_t*)_TIFFmalloc(count * 4); if (data==0) { _TIFFfree(origdata); @@ -1870,62 +1869,62 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntrySlongArray(TIFF* tif, TIFFDirEnt { case TIFF_BYTE: { - uint8* ma; - int32* mb; - uint32 n; - ma=(uint8*)origdata; + uint8_t* ma; + int32_t* mb; + uint32_t n; + ma=(uint8_t*)origdata; mb=data; for (n=0; n<count; n++) - *mb++=(int32)(*ma++); + *mb++=(int32_t)(*ma++); } break; case TIFF_SBYTE: { - int8* ma; - int32* mb; - uint32 n; - ma=(int8*)origdata; + int8_t* ma; + int32_t* mb; + uint32_t n; + ma=(int8_t*)origdata; mb=data; for (n=0; n<count; n++) - *mb++=(int32)(*ma++); + *mb++=(int32_t)(*ma++); } break; case TIFF_SHORT: { - uint16* ma; - int32* mb; - uint32 n; - ma=(uint16*)origdata; + uint16_t* ma; + int32_t* mb; + uint32_t n; + ma=(uint16_t*)origdata; mb=data; for (n=0; n<count; n++) { if (tif->tif_flags&TIFF_SWAB) TIFFSwabShort(ma); - *mb++=(int32)(*ma++); + *mb++=(int32_t)(*ma++); } } break; case TIFF_SSHORT: { - int16* ma; - int32* mb; - uint32 n; - ma=(int16*)origdata; + int16_t* ma; + int32_t* mb; + uint32_t n; + ma=(int16_t*)origdata; mb=data; for (n=0; n<count; n++) { if (tif->tif_flags&TIFF_SWAB) - TIFFSwabShort((uint16*)ma); - *mb++=(int32)(*ma++); + TIFFSwabShort((uint16_t*)ma); + *mb++=(int32_t)(*ma++); } } break; case TIFF_LONG8: { - uint64* ma; - int32* mb; - uint32 n; - ma=(uint64*)origdata; + uint64_t* ma; + int32_t* mb; + uint32_t n; + ma=(uint64_t*)origdata; mb=data; for (n=0; n<count; n++) { @@ -1934,25 +1933,25 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntrySlongArray(TIFF* tif, TIFFDirEnt err=TIFFReadDirEntryCheckRangeSlongLong8(*ma); if (err!=TIFFReadDirEntryErrOk) break; - *mb++=(int32)(*ma++); + *mb++=(int32_t)(*ma++); } } break; case TIFF_SLONG8: { - int64* ma; - int32* mb; - uint32 n; - ma=(int64*)origdata; + int64_t* ma; + int32_t* mb; + uint32_t n; + ma=(int64_t*)origdata; mb=data; for (n=0; n<count; n++) { if (tif->tif_flags&TIFF_SWAB) - TIFFSwabLong8((uint64*)ma); + TIFFSwabLong8((uint64_t*)ma); err=TIFFReadDirEntryCheckRangeSlongSlong8(*ma); if (err!=TIFFReadDirEntryErrOk) break; - *mb++=(int32)(*ma++); + *mb++=(int32_t)(*ma++); } } break; @@ -1968,12 +1967,12 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntrySlongArray(TIFF* tif, TIFFDirEnt } static enum TIFFReadDirEntryErr TIFFReadDirEntryLong8ArrayWithLimit( - TIFF* tif, TIFFDirEntry* direntry, uint64** value, uint64 maxcount) + TIFF* tif, TIFFDirEntry* direntry, uint64_t** value, uint64_t maxcount) { enum TIFFReadDirEntryErr err; - uint32 count; + uint32_t count; void* origdata; - uint64* data; + uint64_t* data; switch (direntry->tdir_type) { case TIFF_BYTE: @@ -1997,19 +1996,19 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryLong8ArrayWithLimit( switch (direntry->tdir_type) { case TIFF_LONG8: - *value=(uint64*)origdata; + *value=(uint64_t*)origdata; if (tif->tif_flags&TIFF_SWAB) TIFFSwabArrayOfLong8(*value,count); return(TIFFReadDirEntryErrOk); case TIFF_SLONG8: { - int64* m; - uint32 n; - m=(int64*)origdata; + int64_t* m; + uint32_t n; + m=(int64_t*)origdata; for (n=0; n<count; n++) { if (tif->tif_flags&TIFF_SWAB) - TIFFSwabLong8((uint64*)m); + TIFFSwabLong8((uint64_t*)m); err=TIFFReadDirEntryCheckRangeLong8Slong8(*m); if (err!=TIFFReadDirEntryErrOk) { @@ -2018,11 +2017,11 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryLong8ArrayWithLimit( } m++; } - *value=(uint64*)origdata; + *value=(uint64_t*)origdata; return(TIFFReadDirEntryErrOk); } } - data=(uint64*)_TIFFmalloc(count*8); + data=(uint64_t*)_TIFFmalloc(count * 8); if (data==0) { _TIFFfree(origdata); @@ -2032,94 +2031,94 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryLong8ArrayWithLimit( { case TIFF_BYTE: { - uint8* ma; - uint64* mb; - uint32 n; - ma=(uint8*)origdata; + uint8_t* ma; + uint64_t* mb; + uint32_t n; + ma=(uint8_t*)origdata; mb=data; for (n=0; n<count; n++) - *mb++=(uint64)(*ma++); + *mb++=(uint64_t)(*ma++); } break; case TIFF_SBYTE: { - int8* ma; - uint64* mb; - uint32 n; - ma=(int8*)origdata; + int8_t* ma; + uint64_t* mb; + uint32_t n; + ma=(int8_t*)origdata; mb=data; for (n=0; n<count; n++) { err=TIFFReadDirEntryCheckRangeLong8Sbyte(*ma); if (err!=TIFFReadDirEntryErrOk) break; - *mb++=(uint64)(*ma++); + *mb++=(uint64_t)(*ma++); } } break; case TIFF_SHORT: { - uint16* ma; - uint64* mb; - uint32 n; - ma=(uint16*)origdata; + uint16_t* ma; + uint64_t* mb; + uint32_t n; + ma=(uint16_t*)origdata; mb=data; for (n=0; n<count; n++) { if (tif->tif_flags&TIFF_SWAB) TIFFSwabShort(ma); - *mb++=(uint64)(*ma++); + *mb++=(uint64_t)(*ma++); } } break; case TIFF_SSHORT: { - int16* ma; - uint64* mb; - uint32 n; - ma=(int16*)origdata; + int16_t* ma; + uint64_t* mb; + uint32_t n; + ma=(int16_t*)origdata; mb=data; for (n=0; n<count; n++) { if (tif->tif_flags&TIFF_SWAB) - TIFFSwabShort((uint16*)ma); + TIFFSwabShort((uint16_t*)ma); err=TIFFReadDirEntryCheckRangeLong8Sshort(*ma); if (err!=TIFFReadDirEntryErrOk) break; - *mb++=(uint64)(*ma++); + *mb++=(uint64_t)(*ma++); } } break; case TIFF_LONG: { - uint32* ma; - uint64* mb; - uint32 n; - ma=(uint32*)origdata; + uint32_t* ma; + uint64_t* mb; + uint32_t n; + ma=(uint32_t*)origdata; mb=data; for (n=0; n<count; n++) { if (tif->tif_flags&TIFF_SWAB) TIFFSwabLong(ma); - *mb++=(uint64)(*ma++); + *mb++=(uint64_t)(*ma++); } } break; case TIFF_SLONG: { - int32* ma; - uint64* mb; - uint32 n; - ma=(int32*)origdata; + int32_t* ma; + uint64_t* mb; + uint32_t n; + ma=(int32_t*)origdata; mb=data; for (n=0; n<count; n++) { if (tif->tif_flags&TIFF_SWAB) - TIFFSwabLong((uint32*)ma); + TIFFSwabLong((uint32_t*)ma); err=TIFFReadDirEntryCheckRangeLong8Slong(*ma); if (err!=TIFFReadDirEntryErrOk) break; - *mb++=(uint64)(*ma++); + *mb++=(uint64_t)(*ma++); } } break; @@ -2134,17 +2133,17 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryLong8ArrayWithLimit( return(TIFFReadDirEntryErrOk); } -static enum TIFFReadDirEntryErr TIFFReadDirEntryLong8Array(TIFF* tif, TIFFDirEntry* direntry, uint64** value) +static enum TIFFReadDirEntryErr TIFFReadDirEntryLong8Array(TIFF* tif, TIFFDirEntry* direntry, uint64_t** value) { - return TIFFReadDirEntryLong8ArrayWithLimit(tif, direntry, value, ~((uint64)0)); + return TIFFReadDirEntryLong8ArrayWithLimit(tif, direntry, value, ~((uint64_t)0)); } -static enum TIFFReadDirEntryErr TIFFReadDirEntrySlong8Array(TIFF* tif, TIFFDirEntry* direntry, int64** value) +static enum TIFFReadDirEntryErr TIFFReadDirEntrySlong8Array(TIFF* tif, TIFFDirEntry* direntry, int64_t** value) { enum TIFFReadDirEntryErr err; - uint32 count; + uint32_t count; void* origdata; - int64* data; + int64_t* data; switch (direntry->tdir_type) { case TIFF_BYTE: @@ -2169,9 +2168,9 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntrySlong8Array(TIFF* tif, TIFFDirEn { case TIFF_LONG8: { - uint64* m; - uint32 n; - m=(uint64*)origdata; + uint64_t* m; + uint32_t n; + m=(uint64_t*)origdata; for (n=0; n<count; n++) { if (tif->tif_flags&TIFF_SWAB) @@ -2184,16 +2183,16 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntrySlong8Array(TIFF* tif, TIFFDirEn } m++; } - *value=(int64*)origdata; + *value=(int64_t*)origdata; return(TIFFReadDirEntryErrOk); } case TIFF_SLONG8: - *value=(int64*)origdata; + *value=(int64_t*)origdata; if (tif->tif_flags&TIFF_SWAB) - TIFFSwabArrayOfLong8((uint64*)(*value),count); + TIFFSwabArrayOfLong8((uint64_t*)(*value), count); return(TIFFReadDirEntryErrOk); } - data=(int64*)_TIFFmalloc(count*8); + data=(int64_t*)_TIFFmalloc(count * 8); if (data==0) { _TIFFfree(origdata); @@ -2203,83 +2202,83 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntrySlong8Array(TIFF* tif, TIFFDirEn { case TIFF_BYTE: { - uint8* ma; - int64* mb; - uint32 n; - ma=(uint8*)origdata; + uint8_t* ma; + int64_t* mb; + uint32_t n; + ma=(uint8_t*)origdata; mb=data; for (n=0; n<count; n++) - *mb++=(int64)(*ma++); + *mb++=(int64_t)(*ma++); } break; case TIFF_SBYTE: { - int8* ma; - int64* mb; - uint32 n; - ma=(int8*)origdata; + int8_t* ma; + int64_t* mb; + uint32_t n; + ma=(int8_t*)origdata; mb=data; for (n=0; n<count; n++) - *mb++=(int64)(*ma++); + *mb++=(int64_t)(*ma++); } break; case TIFF_SHORT: { - uint16* ma; - int64* mb; - uint32 n; - ma=(uint16*)origdata; + uint16_t* ma; + int64_t* mb; + uint32_t n; + ma=(uint16_t*)origdata; mb=data; for (n=0; n<count; n++) { if (tif->tif_flags&TIFF_SWAB) TIFFSwabShort(ma); - *mb++=(int64)(*ma++); + *mb++=(int64_t)(*ma++); } } break; case TIFF_SSHORT: { - int16* ma; - int64* mb; - uint32 n; - ma=(int16*)origdata; + int16_t* ma; + int64_t* mb; + uint32_t n; + ma=(int16_t*)origdata; mb=data; for (n=0; n<count; n++) { if (tif->tif_flags&TIFF_SWAB) - TIFFSwabShort((uint16*)ma); - *mb++=(int64)(*ma++); + TIFFSwabShort((uint16_t*)ma); + *mb++=(int64_t)(*ma++); } } break; case TIFF_LONG: { - uint32* ma; - int64* mb; - uint32 n; - ma=(uint32*)origdata; + uint32_t* ma; + int64_t* mb; + uint32_t n; + ma=(uint32_t*)origdata; mb=data; for (n=0; n<count; n++) { if (tif->tif_flags&TIFF_SWAB) TIFFSwabLong(ma); - *mb++=(int64)(*ma++); + *mb++=(int64_t)(*ma++); } } break; case TIFF_SLONG: { - int32* ma; - int64* mb; - uint32 n; - ma=(int32*)origdata; + int32_t* ma; + int64_t* mb; + uint32_t n; + ma=(int32_t*)origdata; mb=data; for (n=0; n<count; n++) { if (tif->tif_flags&TIFF_SWAB) - TIFFSwabLong((uint32*)ma); - *mb++=(int64)(*ma++); + TIFFSwabLong((uint32_t*)ma); + *mb++=(int64_t)(*ma++); } } break; @@ -2292,7 +2291,7 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntrySlong8Array(TIFF* tif, TIFFDirEn static enum TIFFReadDirEntryErr TIFFReadDirEntryFloatArray(TIFF* tif, TIFFDirEntry* direntry, float** value) { enum TIFFReadDirEntryErr err; - uint32 count; + uint32_t count; void* origdata; float* data; switch (direntry->tdir_type) @@ -2323,7 +2322,7 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryFloatArray(TIFF* tif, TIFFDirEnt { case TIFF_FLOAT: if (tif->tif_flags&TIFF_SWAB) - TIFFSwabArrayOfLong((uint32*)origdata,count); + TIFFSwabArrayOfLong((uint32_t*)origdata, count); TIFFCvtIEEEDoubleToNative(tif,count,(float*)origdata); *value=(float*)origdata; return(TIFFReadDirEntryErrOk); @@ -2338,10 +2337,10 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryFloatArray(TIFF* tif, TIFFDirEnt { case TIFF_BYTE: { - uint8* ma; + uint8_t* ma; float* mb; - uint32 n; - ma=(uint8*)origdata; + uint32_t n; + ma=(uint8_t*)origdata; mb=data; for (n=0; n<count; n++) *mb++=(float)(*ma++); @@ -2349,10 +2348,10 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryFloatArray(TIFF* tif, TIFFDirEnt break; case TIFF_SBYTE: { - int8* ma; + int8_t* ma; float* mb; - uint32 n; - ma=(int8*)origdata; + uint32_t n; + ma=(int8_t*)origdata; mb=data; for (n=0; n<count; n++) *mb++=(float)(*ma++); @@ -2360,10 +2359,10 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryFloatArray(TIFF* tif, TIFFDirEnt break; case TIFF_SHORT: { - uint16* ma; + uint16_t* ma; float* mb; - uint32 n; - ma=(uint16*)origdata; + uint32_t n; + ma=(uint16_t*)origdata; mb=data; for (n=0; n<count; n++) { @@ -2375,25 +2374,25 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryFloatArray(TIFF* tif, TIFFDirEnt break; case TIFF_SSHORT: { - int16* ma; + int16_t* ma; float* mb; - uint32 n; - ma=(int16*)origdata; + uint32_t n; + ma=(int16_t*)origdata; mb=data; for (n=0; n<count; n++) { if (tif->tif_flags&TIFF_SWAB) - TIFFSwabShort((uint16*)ma); + TIFFSwabShort((uint16_t*)ma); *mb++=(float)(*ma++); } } break; case TIFF_LONG: { - uint32* ma; + uint32_t* ma; float* mb; - uint32 n; - ma=(uint32*)origdata; + uint32_t n; + ma=(uint32_t*)origdata; mb=data; for (n=0; n<count; n++) { @@ -2405,25 +2404,25 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryFloatArray(TIFF* tif, TIFFDirEnt break; case TIFF_SLONG: { - int32* ma; + int32_t* ma; float* mb; - uint32 n; - ma=(int32*)origdata; + uint32_t n; + ma=(int32_t*)origdata; mb=data; for (n=0; n<count; n++) { if (tif->tif_flags&TIFF_SWAB) - TIFFSwabLong((uint32*)ma); + TIFFSwabLong((uint32_t*)ma); *mb++=(float)(*ma++); } } break; case TIFF_LONG8: { - uint64* ma; + uint64_t* ma; float* mb; - uint32 n; - ma=(uint64*)origdata; + uint32_t n; + ma=(uint64_t*)origdata; mb=data; for (n=0; n<count; n++) { @@ -2444,27 +2443,27 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryFloatArray(TIFF* tif, TIFFDirEnt break; case TIFF_SLONG8: { - int64* ma; + int64_t* ma; float* mb; - uint32 n; - ma=(int64*)origdata; + uint32_t n; + ma=(int64_t*)origdata; mb=data; for (n=0; n<count; n++) { if (tif->tif_flags&TIFF_SWAB) - TIFFSwabLong8((uint64*)ma); + TIFFSwabLong8((uint64_t*)ma); *mb++=(float)(*ma++); } } break; case TIFF_RATIONAL: { - uint32* ma; - uint32 maa; - uint32 mab; + uint32_t* ma; + uint32_t maa; + uint32_t mab; float* mb; - uint32 n; - ma=(uint32*)origdata; + uint32_t n; + ma=(uint32_t*)origdata; mb=data; for (n=0; n<count; n++) { @@ -2483,18 +2482,18 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryFloatArray(TIFF* tif, TIFFDirEnt break; case TIFF_SRATIONAL: { - uint32* ma; - int32 maa; - uint32 mab; + uint32_t* ma; + int32_t maa; + uint32_t mab; float* mb; - uint32 n; - ma=(uint32*)origdata; + uint32_t n; + ma=(uint32_t*)origdata; mb=data; for (n=0; n<count; n++) { if (tif->tif_flags&TIFF_SWAB) TIFFSwabLong(ma); - maa=*(int32*)ma; + maa=*(int32_t*)ma; ma++; if (tif->tif_flags&TIFF_SWAB) TIFFSwabLong(ma); @@ -2510,9 +2509,9 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryFloatArray(TIFF* tif, TIFFDirEnt { double* ma; float* mb; - uint32 n; + uint32_t n; if (tif->tif_flags&TIFF_SWAB) - TIFFSwabArrayOfLong8((uint64*)origdata,count); + TIFFSwabArrayOfLong8((uint64_t*)origdata, count); TIFFCvtIEEEDoubleToNative(tif,count,(double*)origdata); ma=(double*)origdata; mb=data; @@ -2537,7 +2536,7 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryDoubleArray(TIFF* tif, TIFFDirEntry* direntry, double** value) { enum TIFFReadDirEntryErr err; - uint32 count; + uint32_t count; void* origdata; double* data; switch (direntry->tdir_type) @@ -2568,7 +2567,7 @@ TIFFReadDirEntryDoubleArray(TIFF* tif, TIFFDirEntry* direntry, double** value) { case TIFF_DOUBLE: if (tif->tif_flags&TIFF_SWAB) - TIFFSwabArrayOfLong8((uint64*)origdata,count); + TIFFSwabArrayOfLong8((uint64_t*)origdata, count); TIFFCvtIEEEDoubleToNative(tif,count,(double*)origdata); *value=(double*)origdata; return(TIFFReadDirEntryErrOk); @@ -2583,10 +2582,10 @@ TIFFReadDirEntryDoubleArray(TIFF* tif, TIFFDirEntry* direntry, double** value) { case TIFF_BYTE: { - uint8* ma; + uint8_t* ma; double* mb; - uint32 n; - ma=(uint8*)origdata; + uint32_t n; + ma=(uint8_t*)origdata; mb=data; for (n=0; n<count; n++) *mb++=(double)(*ma++); @@ -2594,10 +2593,10 @@ TIFFReadDirEntryDoubleArray(TIFF* tif, TIFFDirEntry* direntry, double** value) break; case TIFF_SBYTE: { - int8* ma; + int8_t* ma; double* mb; - uint32 n; - ma=(int8*)origdata; + uint32_t n; + ma=(int8_t*)origdata; mb=data; for (n=0; n<count; n++) *mb++=(double)(*ma++); @@ -2605,10 +2604,10 @@ TIFFReadDirEntryDoubleArray(TIFF* tif, TIFFDirEntry* direntry, double** value) break; case TIFF_SHORT: { - uint16* ma; + uint16_t* ma; double* mb; - uint32 n; - ma=(uint16*)origdata; + uint32_t n; + ma=(uint16_t*)origdata; mb=data; for (n=0; n<count; n++) { @@ -2620,25 +2619,25 @@ TIFFReadDirEntryDoubleArray(TIFF* tif, TIFFDirEntry* direntry, double** value) break; case TIFF_SSHORT: { - int16* ma; + int16_t* ma; double* mb; - uint32 n; - ma=(int16*)origdata; + uint32_t n; + ma=(int16_t*)origdata; mb=data; for (n=0; n<count; n++) { if (tif->tif_flags&TIFF_SWAB) - TIFFSwabShort((uint16*)ma); + TIFFSwabShort((uint16_t*)ma); *mb++=(double)(*ma++); } } break; case TIFF_LONG: { - uint32* ma; + uint32_t* ma; double* mb; - uint32 n; - ma=(uint32*)origdata; + uint32_t n; + ma=(uint32_t*)origdata; mb=data; for (n=0; n<count; n++) { @@ -2650,25 +2649,25 @@ TIFFReadDirEntryDoubleArray(TIFF* tif, TIFFDirEntry* direntry, double** value) break; case TIFF_SLONG: { - int32* ma; + int32_t* ma; double* mb; - uint32 n; - ma=(int32*)origdata; + uint32_t n; + ma=(int32_t*)origdata; mb=data; for (n=0; n<count; n++) { if (tif->tif_flags&TIFF_SWAB) - TIFFSwabLong((uint32*)ma); + TIFFSwabLong((uint32_t*)ma); *mb++=(double)(*ma++); } } break; case TIFF_LONG8: { - uint64* ma; + uint64_t* ma; double* mb; - uint32 n; - ma=(uint64*)origdata; + uint32_t n; + ma=(uint64_t*)origdata; mb=data; for (n=0; n<count; n++) { @@ -2689,27 +2688,27 @@ TIFFReadDirEntryDoubleArray(TIFF* tif, TIFFDirEntry* direntry, double** value) break; case TIFF_SLONG8: { - int64* ma; + int64_t* ma; double* mb; - uint32 n; - ma=(int64*)origdata; + uint32_t n; + ma=(int64_t*)origdata; mb=data; for (n=0; n<count; n++) { if (tif->tif_flags&TIFF_SWAB) - TIFFSwabLong8((uint64*)ma); + TIFFSwabLong8((uint64_t*)ma); *mb++=(double)(*ma++); } } break; case TIFF_RATIONAL: { - uint32* ma; - uint32 maa; - uint32 mab; + uint32_t* ma; + uint32_t maa; + uint32_t mab; double* mb; - uint32 n; - ma=(uint32*)origdata; + uint32_t n; + ma=(uint32_t*)origdata; mb=data; for (n=0; n<count; n++) { @@ -2728,18 +2727,18 @@ TIFFReadDirEntryDoubleArray(TIFF* tif, TIFFDirEntry* direntry, double** value) break; case TIFF_SRATIONAL: { - uint32* ma; - int32 maa; - uint32 mab; + uint32_t* ma; + int32_t maa; + uint32_t mab; double* mb; - uint32 n; - ma=(uint32*)origdata; + uint32_t n; + ma=(uint32_t*)origdata; mb=data; for (n=0; n<count; n++) { if (tif->tif_flags&TIFF_SWAB) TIFFSwabLong(ma); - maa=*(int32*)ma; + maa=*(int32_t*)ma; ma++; if (tif->tif_flags&TIFF_SWAB) TIFFSwabLong(ma); @@ -2755,9 +2754,9 @@ TIFFReadDirEntryDoubleArray(TIFF* tif, TIFFDirEntry* direntry, double** value) { float* ma; double* mb; - uint32 n; + uint32_t n; if (tif->tif_flags&TIFF_SWAB) - TIFFSwabArrayOfLong((uint32*)origdata,count); + TIFFSwabArrayOfLong((uint32_t*)origdata, count); TIFFCvtIEEEFloatToNative(tif,count,(float*)origdata); ma=(float*)origdata; mb=data; @@ -2771,12 +2770,12 @@ TIFFReadDirEntryDoubleArray(TIFF* tif, TIFFDirEntry* direntry, double** value) return(TIFFReadDirEntryErrOk); } -static enum TIFFReadDirEntryErr TIFFReadDirEntryIfd8Array(TIFF* tif, TIFFDirEntry* direntry, uint64** value) +static enum TIFFReadDirEntryErr TIFFReadDirEntryIfd8Array(TIFF* tif, TIFFDirEntry* direntry, uint64_t** value) { enum TIFFReadDirEntryErr err; - uint32 count; + uint32_t count; void* origdata; - uint64* data; + uint64_t* data; switch (direntry->tdir_type) { case TIFF_LONG: @@ -2797,12 +2796,12 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryIfd8Array(TIFF* tif, TIFFDirEntr { case TIFF_LONG8: case TIFF_IFD8: - *value=(uint64*)origdata; + *value=(uint64_t*)origdata; if (tif->tif_flags&TIFF_SWAB) TIFFSwabArrayOfLong8(*value,count); return(TIFFReadDirEntryErrOk); } - data=(uint64*)_TIFFmalloc(count*8); + data=(uint64_t*)_TIFFmalloc(count * 8); if (data==0) { _TIFFfree(origdata); @@ -2813,16 +2812,16 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryIfd8Array(TIFF* tif, TIFFDirEntr case TIFF_LONG: case TIFF_IFD: { - uint32* ma; - uint64* mb; - uint32 n; - ma=(uint32*)origdata; + uint32_t* ma; + uint64_t* mb; + uint32_t n; + ma=(uint32_t*)origdata; mb=data; for (n=0; n<count; n++) { if (tif->tif_flags&TIFF_SWAB) TIFFSwabLong(ma); - *mb++=(uint64)(*ma++); + *mb++=(uint64_t)(*ma++); } } break; @@ -2832,13 +2831,13 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryIfd8Array(TIFF* tif, TIFFDirEntr return(TIFFReadDirEntryErrOk); } -static enum TIFFReadDirEntryErr TIFFReadDirEntryPersampleShort(TIFF* tif, TIFFDirEntry* direntry, uint16* value) +static enum TIFFReadDirEntryErr TIFFReadDirEntryPersampleShort(TIFF* tif, TIFFDirEntry* direntry, uint16_t* value) { enum TIFFReadDirEntryErr err; - uint16* m; - uint16* na; - uint16 nb; - if (direntry->tdir_count<(uint64)tif->tif_dir.td_samplesperpixel) + uint16_t* m; + uint16_t* na; + uint16_t nb; + if (direntry->tdir_count<(uint64_t)tif->tif_dir.td_samplesperpixel) return(TIFFReadDirEntryErrCount); err=TIFFReadDirEntryShortArray(tif,direntry,&m); if (err!=TIFFReadDirEntryErrOk || m == NULL) @@ -2866,8 +2865,8 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryPersampleDouble(TIFF* tif, TIFFD enum TIFFReadDirEntryErr err; double* m; double* na; - uint16 nb; - if (direntry->tdir_count<(uint64)tif->tif_dir.td_samplesperpixel) + uint16_t nb; + if (direntry->tdir_count<(uint64_t)tif->tif_dir.td_samplesperpixel) return(TIFFReadDirEntryErrCount); err=TIFFReadDirEntryDoubleArray(tif,direntry,&m); if (err!=TIFFReadDirEntryErrOk) @@ -2890,53 +2889,53 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryPersampleDouble(TIFF* tif, TIFFD } #endif -static void TIFFReadDirEntryCheckedByte(TIFF* tif, TIFFDirEntry* direntry, uint8* value) +static void TIFFReadDirEntryCheckedByte(TIFF* tif, TIFFDirEntry* direntry, uint8_t* value) { (void) tif; - *value=*(uint8*)(&direntry->tdir_offset); + *value=*(uint8_t*)(&direntry->tdir_offset); } -static void TIFFReadDirEntryCheckedSbyte(TIFF* tif, TIFFDirEntry* direntry, int8* value) +static void TIFFReadDirEntryCheckedSbyte(TIFF* tif, TIFFDirEntry* direntry, int8_t* value) { (void) tif; - *value=*(int8*)(&direntry->tdir_offset); + *value=*(int8_t*)(&direntry->tdir_offset); } -static void TIFFReadDirEntryCheckedShort(TIFF* tif, TIFFDirEntry* direntry, uint16* value) +static void TIFFReadDirEntryCheckedShort(TIFF* tif, TIFFDirEntry* direntry, uint16_t* value) { *value = direntry->tdir_offset.toff_short; - /* *value=*(uint16*)(&direntry->tdir_offset); */ + /* *value=*(uint16_t*)(&direntry->tdir_offset); */ if (tif->tif_flags&TIFF_SWAB) TIFFSwabShort(value); } -static void TIFFReadDirEntryCheckedSshort(TIFF* tif, TIFFDirEntry* direntry, int16* value) +static void TIFFReadDirEntryCheckedSshort(TIFF* tif, TIFFDirEntry* direntry, int16_t* value) { - *value=*(int16*)(&direntry->tdir_offset); + *value=*(int16_t*)(&direntry->tdir_offset); if (tif->tif_flags&TIFF_SWAB) - TIFFSwabShort((uint16*)value); + TIFFSwabShort((uint16_t*)value); } -static void TIFFReadDirEntryCheckedLong(TIFF* tif, TIFFDirEntry* direntry, uint32* value) +static void TIFFReadDirEntryCheckedLong(TIFF* tif, TIFFDirEntry* direntry, uint32_t* value) { - *value=*(uint32*)(&direntry->tdir_offset); + *value=*(uint32_t*)(&direntry->tdir_offset); if (tif->tif_flags&TIFF_SWAB) TIFFSwabLong(value); } -static void TIFFReadDirEntryCheckedSlong(TIFF* tif, TIFFDirEntry* direntry, int32* value) +static void TIFFReadDirEntryCheckedSlong(TIFF* tif, TIFFDirEntry* direntry, int32_t* value) { - *value=*(int32*)(&direntry->tdir_offset); + *value=*(int32_t*)(&direntry->tdir_offset); if (tif->tif_flags&TIFF_SWAB) - TIFFSwabLong((uint32*)value); + TIFFSwabLong((uint32_t*)value); } -static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckedLong8(TIFF* tif, TIFFDirEntry* direntry, uint64* value) +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckedLong8(TIFF* tif, TIFFDirEntry* direntry, uint64_t* value) { if (!(tif->tif_flags&TIFF_BIGTIFF)) { enum TIFFReadDirEntryErr err; - uint32 offset = direntry->tdir_offset.toff_long; + uint32_t offset = direntry->tdir_offset.toff_long; if (tif->tif_flags&TIFF_SWAB) TIFFSwabLong(&offset); err=TIFFReadDirEntryData(tif,offset,8,value); @@ -2950,12 +2949,12 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckedLong8(TIFF* tif, TIFFDirE return(TIFFReadDirEntryErrOk); } -static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckedSlong8(TIFF* tif, TIFFDirEntry* direntry, int64* value) +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckedSlong8(TIFF* tif, TIFFDirEntry* direntry, int64_t* value) { if (!(tif->tif_flags&TIFF_BIGTIFF)) { enum TIFFReadDirEntryErr err; - uint32 offset = direntry->tdir_offset.toff_long; + uint32_t offset = direntry->tdir_offset.toff_long; if (tif->tif_flags&TIFF_SWAB) TIFFSwabLong(&offset); err=TIFFReadDirEntryData(tif,offset,8,value); @@ -2963,9 +2962,9 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckedSlong8(TIFF* tif, TIFFDir return(err); } else - *value=*(int64*)(&direntry->tdir_offset); + *value=*(int64_t*)(&direntry->tdir_offset); if (tif->tif_flags&TIFF_SWAB) - TIFFSwabLong8((uint64*)value); + TIFFSwabLong8((uint64_t*)value); return(TIFFReadDirEntryErrOk); } @@ -2974,12 +2973,12 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckedRational(TIFF* tif, TIFFD UInt64Aligned_t m; assert(sizeof(double)==8); - assert(sizeof(uint64)==8); - assert(sizeof(uint32)==4); + assert(sizeof(uint64_t) == 8); + assert(sizeof(uint32_t) == 4); if (!(tif->tif_flags&TIFF_BIGTIFF)) { enum TIFFReadDirEntryErr err; - uint32 offset = direntry->tdir_offset.toff_long; + uint32_t offset = direntry->tdir_offset.toff_long; if (tif->tif_flags&TIFF_SWAB) TIFFSwabLong(&offset); err=TIFFReadDirEntryData(tif,offset,8,m.i); @@ -3004,13 +3003,13 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckedSrational(TIFF* tif, TIFF { UInt64Aligned_t m; assert(sizeof(double)==8); - assert(sizeof(uint64)==8); - assert(sizeof(int32)==4); - assert(sizeof(uint32)==4); + assert(sizeof(uint64_t) == 8); + assert(sizeof(int32_t) == 4); + assert(sizeof(uint32_t) == 4); if (!(tif->tif_flags&TIFF_BIGTIFF)) { enum TIFFReadDirEntryErr err; - uint32 offset = direntry->tdir_offset.toff_long; + uint32_t offset = direntry->tdir_offset.toff_long; if (tif->tif_flags&TIFF_SWAB) TIFFSwabLong(&offset); err=TIFFReadDirEntryData(tif,offset,8,m.i); @@ -3024,10 +3023,10 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckedSrational(TIFF* tif, TIFF /* Not completely sure what we should do when m.i[1]==0, but some */ /* sanitizers do not like division by 0.0: */ /* http://bugzilla.maptools.org/show_bug.cgi?id=2644 */ - if ((int32)m.i[0]==0 || m.i[1]==0) + if ((int32_t)m.i[0] == 0 || m.i[1] == 0) *value=0.0; else - *value=(double)((int32)m.i[0])/(double)m.i[1]; + *value= (double)((int32_t)m.i[0]) / (double)m.i[1]; return(TIFFReadDirEntryErrOk); } @@ -3036,26 +3035,26 @@ static void TIFFReadDirEntryCheckedFloat(TIFF* tif, TIFFDirEntry* direntry, floa union { float f; - uint32 i; + uint32_t i; } float_union; assert(sizeof(float)==4); - assert(sizeof(uint32)==4); + assert(sizeof(uint32_t) == 4); assert(sizeof(float_union)==4); - float_union.i=*(uint32*)(&direntry->tdir_offset); + float_union.i=*(uint32_t*)(&direntry->tdir_offset); *value=float_union.f; if (tif->tif_flags&TIFF_SWAB) - TIFFSwabLong((uint32*)value); + TIFFSwabLong((uint32_t*)value); } static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckedDouble(TIFF* tif, TIFFDirEntry* direntry, double* value) { assert(sizeof(double)==8); - assert(sizeof(uint64)==8); + assert(sizeof(uint64_t) == 8); assert(sizeof(UInt64Aligned_t)==8); if (!(tif->tif_flags&TIFF_BIGTIFF)) { enum TIFFReadDirEntryErr err; - uint32 offset = direntry->tdir_offset.toff_long; + uint32_t offset = direntry->tdir_offset.toff_long; if (tif->tif_flags&TIFF_SWAB) TIFFSwabLong(&offset); err=TIFFReadDirEntryData(tif,offset,8,value); @@ -3069,11 +3068,11 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckedDouble(TIFF* tif, TIFFDir *value=uint64_union.d; } if (tif->tif_flags&TIFF_SWAB) - TIFFSwabLong8((uint64*)value); + TIFFSwabLong8((uint64_t*)value); return(TIFFReadDirEntryErrOk); } -static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeByteSbyte(int8 value) +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeByteSbyte(int8_t value) { if (value<0) return(TIFFReadDirEntryErrRange); @@ -3081,7 +3080,7 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeByteSbyte(int8 value) return(TIFFReadDirEntryErrOk); } -static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeByteShort(uint16 value) +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeByteShort(uint16_t value) { if (value>0xFF) return(TIFFReadDirEntryErrRange); @@ -3089,7 +3088,7 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeByteShort(uint16 value return(TIFFReadDirEntryErrOk); } -static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeByteSshort(int16 value) +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeByteSshort(int16_t value) { if ((value<0)||(value>0xFF)) return(TIFFReadDirEntryErrRange); @@ -3097,7 +3096,7 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeByteSshort(int16 value return(TIFFReadDirEntryErrOk); } -static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeByteLong(uint32 value) +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeByteLong(uint32_t value) { if (value>0xFF) return(TIFFReadDirEntryErrRange); @@ -3105,7 +3104,7 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeByteLong(uint32 value) return(TIFFReadDirEntryErrOk); } -static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeByteSlong(int32 value) +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeByteSlong(int32_t value) { if ((value<0)||(value>0xFF)) return(TIFFReadDirEntryErrRange); @@ -3113,7 +3112,7 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeByteSlong(int32 value) return(TIFFReadDirEntryErrOk); } -static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeByteLong8(uint64 value) +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeByteLong8(uint64_t value) { if (value>0xFF) return(TIFFReadDirEntryErrRange); @@ -3121,7 +3120,7 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeByteLong8(uint64 value return(TIFFReadDirEntryErrOk); } -static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeByteSlong8(int64 value) +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeByteSlong8(int64_t value) { if ((value<0)||(value>0xFF)) return(TIFFReadDirEntryErrRange); @@ -3129,7 +3128,7 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeByteSlong8(int64 value return(TIFFReadDirEntryErrOk); } -static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSbyteByte(uint8 value) +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSbyteByte(uint8_t value) { if (value>0x7F) return(TIFFReadDirEntryErrRange); @@ -3137,7 +3136,7 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSbyteByte(uint8 value) return(TIFFReadDirEntryErrOk); } -static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSbyteShort(uint16 value) +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSbyteShort(uint16_t value) { if (value>0x7F) return(TIFFReadDirEntryErrRange); @@ -3145,7 +3144,7 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSbyteShort(uint16 valu return(TIFFReadDirEntryErrOk); } -static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSbyteSshort(int16 value) +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSbyteSshort(int16_t value) { if ((value<-0x80)||(value>0x7F)) return(TIFFReadDirEntryErrRange); @@ -3153,7 +3152,7 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSbyteSshort(int16 valu return(TIFFReadDirEntryErrOk); } -static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSbyteLong(uint32 value) +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSbyteLong(uint32_t value) { if (value>0x7F) return(TIFFReadDirEntryErrRange); @@ -3161,7 +3160,7 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSbyteLong(uint32 value return(TIFFReadDirEntryErrOk); } -static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSbyteSlong(int32 value) +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSbyteSlong(int32_t value) { if ((value<-0x80)||(value>0x7F)) return(TIFFReadDirEntryErrRange); @@ -3169,7 +3168,7 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSbyteSlong(int32 value return(TIFFReadDirEntryErrOk); } -static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSbyteLong8(uint64 value) +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSbyteLong8(uint64_t value) { if (value>0x7F) return(TIFFReadDirEntryErrRange); @@ -3177,7 +3176,7 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSbyteLong8(uint64 valu return(TIFFReadDirEntryErrOk); } -static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSbyteSlong8(int64 value) +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSbyteSlong8(int64_t value) { if ((value<-0x80)||(value>0x7F)) return(TIFFReadDirEntryErrRange); @@ -3185,7 +3184,7 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSbyteSlong8(int64 valu return(TIFFReadDirEntryErrOk); } -static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeShortSbyte(int8 value) +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeShortSbyte(int8_t value) { if (value<0) return(TIFFReadDirEntryErrRange); @@ -3193,7 +3192,7 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeShortSbyte(int8 value) return(TIFFReadDirEntryErrOk); } -static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeShortSshort(int16 value) +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeShortSshort(int16_t value) { if (value<0) return(TIFFReadDirEntryErrRange); @@ -3201,7 +3200,7 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeShortSshort(int16 valu return(TIFFReadDirEntryErrOk); } -static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeShortLong(uint32 value) +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeShortLong(uint32_t value) { if (value>0xFFFF) return(TIFFReadDirEntryErrRange); @@ -3209,7 +3208,7 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeShortLong(uint32 value return(TIFFReadDirEntryErrOk); } -static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeShortSlong(int32 value) +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeShortSlong(int32_t value) { if ((value<0)||(value>0xFFFF)) return(TIFFReadDirEntryErrRange); @@ -3217,7 +3216,7 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeShortSlong(int32 value return(TIFFReadDirEntryErrOk); } -static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeShortLong8(uint64 value) +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeShortLong8(uint64_t value) { if (value>0xFFFF) return(TIFFReadDirEntryErrRange); @@ -3225,7 +3224,7 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeShortLong8(uint64 valu return(TIFFReadDirEntryErrOk); } -static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeShortSlong8(int64 value) +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeShortSlong8(int64_t value) { if ((value<0)||(value>0xFFFF)) return(TIFFReadDirEntryErrRange); @@ -3233,7 +3232,7 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeShortSlong8(int64 valu return(TIFFReadDirEntryErrOk); } -static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSshortShort(uint16 value) +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSshortShort(uint16_t value) { if (value>0x7FFF) return(TIFFReadDirEntryErrRange); @@ -3241,7 +3240,7 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSshortShort(uint16 val return(TIFFReadDirEntryErrOk); } -static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSshortLong(uint32 value) +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSshortLong(uint32_t value) { if (value>0x7FFF) return(TIFFReadDirEntryErrRange); @@ -3249,7 +3248,7 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSshortLong(uint32 valu return(TIFFReadDirEntryErrOk); } -static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSshortSlong(int32 value) +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSshortSlong(int32_t value) { if ((value<-0x8000)||(value>0x7FFF)) return(TIFFReadDirEntryErrRange); @@ -3257,7 +3256,7 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSshortSlong(int32 valu return(TIFFReadDirEntryErrOk); } -static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSshortLong8(uint64 value) +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSshortLong8(uint64_t value) { if (value>0x7FFF) return(TIFFReadDirEntryErrRange); @@ -3265,7 +3264,7 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSshortLong8(uint64 val return(TIFFReadDirEntryErrOk); } -static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSshortSlong8(int64 value) +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSshortSlong8(int64_t value) { if ((value<-0x8000)||(value>0x7FFF)) return(TIFFReadDirEntryErrRange); @@ -3273,7 +3272,7 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSshortSlong8(int64 val return(TIFFReadDirEntryErrOk); } -static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeLongSbyte(int8 value) +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeLongSbyte(int8_t value) { if (value<0) return(TIFFReadDirEntryErrRange); @@ -3281,7 +3280,7 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeLongSbyte(int8 value) return(TIFFReadDirEntryErrOk); } -static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeLongSshort(int16 value) +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeLongSshort(int16_t value) { if (value<0) return(TIFFReadDirEntryErrRange); @@ -3289,7 +3288,7 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeLongSshort(int16 value return(TIFFReadDirEntryErrOk); } -static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeLongSlong(int32 value) +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeLongSlong(int32_t value) { if (value<0) return(TIFFReadDirEntryErrRange); @@ -3298,25 +3297,25 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeLongSlong(int32 value) } static enum TIFFReadDirEntryErr -TIFFReadDirEntryCheckRangeLongLong8(uint64 value) +TIFFReadDirEntryCheckRangeLongLong8(uint64_t value) { - if (value > TIFF_UINT32_MAX) + if (value > UINT32_MAX) return(TIFFReadDirEntryErrRange); else return(TIFFReadDirEntryErrOk); } static enum TIFFReadDirEntryErr -TIFFReadDirEntryCheckRangeLongSlong8(int64 value) +TIFFReadDirEntryCheckRangeLongSlong8(int64_t value) { - if ((value < 0) || (value > (int64) TIFF_UINT32_MAX)) + if ((value < 0) || (value > (int64_t) UINT32_MAX)) return(TIFFReadDirEntryErrRange); else return(TIFFReadDirEntryErrOk); } static enum TIFFReadDirEntryErr -TIFFReadDirEntryCheckRangeSlongLong(uint32 value) +TIFFReadDirEntryCheckRangeSlongLong(uint32_t value) { if (value > 0x7FFFFFFFUL) return(TIFFReadDirEntryErrRange); @@ -3326,7 +3325,7 @@ TIFFReadDirEntryCheckRangeSlongLong(uint32 value) /* Check that the 8-byte unsigned value can fit in a 4-byte unsigned range */ static enum TIFFReadDirEntryErr -TIFFReadDirEntryCheckRangeSlongLong8(uint64 value) +TIFFReadDirEntryCheckRangeSlongLong8(uint64_t value) { if (value > 0x7FFFFFFF) return(TIFFReadDirEntryErrRange); @@ -3336,16 +3335,16 @@ TIFFReadDirEntryCheckRangeSlongLong8(uint64 value) /* Check that the 8-byte signed value can fit in a 4-byte signed range */ static enum TIFFReadDirEntryErr -TIFFReadDirEntryCheckRangeSlongSlong8(int64 value) +TIFFReadDirEntryCheckRangeSlongSlong8(int64_t value) { - if ((value < 0-((int64) 0x7FFFFFFF+1)) || (value > 0x7FFFFFFF)) + if ((value < 0-((int64_t) 0x7FFFFFFF + 1)) || (value > 0x7FFFFFFF)) return(TIFFReadDirEntryErrRange); else return(TIFFReadDirEntryErrOk); } static enum TIFFReadDirEntryErr -TIFFReadDirEntryCheckRangeLong8Sbyte(int8 value) +TIFFReadDirEntryCheckRangeLong8Sbyte(int8_t value) { if (value < 0) return(TIFFReadDirEntryErrRange); @@ -3354,7 +3353,7 @@ TIFFReadDirEntryCheckRangeLong8Sbyte(int8 value) } static enum TIFFReadDirEntryErr -TIFFReadDirEntryCheckRangeLong8Sshort(int16 value) +TIFFReadDirEntryCheckRangeLong8Sshort(int16_t value) { if (value < 0) return(TIFFReadDirEntryErrRange); @@ -3363,7 +3362,7 @@ TIFFReadDirEntryCheckRangeLong8Sshort(int16 value) } static enum TIFFReadDirEntryErr -TIFFReadDirEntryCheckRangeLong8Slong(int32 value) +TIFFReadDirEntryCheckRangeLong8Slong(int32_t value) { if (value < 0) return(TIFFReadDirEntryErrRange); @@ -3372,7 +3371,7 @@ TIFFReadDirEntryCheckRangeLong8Slong(int32 value) } static enum TIFFReadDirEntryErr -TIFFReadDirEntryCheckRangeLong8Slong8(int64 value) +TIFFReadDirEntryCheckRangeLong8Slong8(int64_t value) { if (value < 0) return(TIFFReadDirEntryErrRange); @@ -3381,16 +3380,16 @@ TIFFReadDirEntryCheckRangeLong8Slong8(int64 value) } static enum TIFFReadDirEntryErr -TIFFReadDirEntryCheckRangeSlong8Long8(uint64 value) +TIFFReadDirEntryCheckRangeSlong8Long8(uint64_t value) { - if (value > TIFF_INT64_MAX) + if (value > INT64_MAX) return(TIFFReadDirEntryErrRange); else return(TIFFReadDirEntryErrOk); } static enum TIFFReadDirEntryErr -TIFFReadDirEntryData(TIFF* tif, uint64 offset, tmsize_t size, void* dest) +TIFFReadDirEntryData(TIFF* tif, uint64_t offset, tmsize_t size, void* dest) { assert(size>0); if (!isMapped(tif)) { @@ -3401,13 +3400,13 @@ TIFFReadDirEntryData(TIFF* tif, uint64 offset, tmsize_t size, void* dest) } else { size_t ma,mb; ma=(size_t)offset; - if( (uint64)ma!=offset || + if((uint64_t)ma != offset || ma > (~(size_t)0) - (size_t)size ) { return TIFFReadDirEntryErrIo; } mb=ma+size; - if (mb > (uint64)tif->tif_size) + if (mb > (uint64_t)tif->tif_size) return(TIFFReadDirEntryErrIo); _TIFFmemcpy(dest,tif->tif_base+ma,size); } @@ -3506,7 +3505,7 @@ static void TIFFReadDirEntryOutputErr(TIFF* tif, enum TIFFReadDirEntryErr err, c * type. 0 is returned if photometric type isn't supported or no default value * is defined by the specification. */ -static int _TIFFGetMaxColorChannels( uint16 photometric ) +static int _TIFFGetMaxColorChannels(uint16_t photometric ) { switch (photometric) { case PHOTOMETRIC_PALETTE: @@ -3545,9 +3544,9 @@ static int ByteCountLooksBad(TIFF* tif) * until the whole image will be written and directory * dumped out. */ - uint64 bytecount = TIFFGetStrileByteCount(tif, 0); - uint64 offset = TIFFGetStrileOffset(tif, 0); - uint64 filesize; + uint64_t bytecount = TIFFGetStrileByteCount(tif, 0); + uint64_t offset = TIFFGetStrileOffset(tif, 0); + uint64_t filesize; if( offset == 0 ) return 0; @@ -3560,9 +3559,9 @@ static int ByteCountLooksBad(TIFF* tif) return 1; if( tif->tif_mode == O_RDONLY ) { - uint64 scanlinesize = TIFFScanlineSize64(tif); + uint64_t scanlinesize = TIFFScanlineSize64(tif); if( tif->tif_dir.td_imagelength > 0 && - scanlinesize > TIFF_UINT64_MAX / tif->tif_dir.td_imagelength ) + scanlinesize > UINT64_MAX / tif->tif_dir.td_imagelength ) { return 1; } @@ -3582,11 +3581,11 @@ TIFFReadDirectory(TIFF* tif) { static const char module[] = "TIFFReadDirectory"; TIFFDirEntry* dir; - uint16 dircount; + uint16_t dircount; TIFFDirEntry* dp; - uint16 di; + uint16_t di; const TIFFField* fip; - uint32 fii=FAILED_FII; + uint32_t fii=FAILED_FII; toff_t nextdiroff; int bitspersample_read = FALSE; int color_channels; @@ -3601,7 +3600,7 @@ TIFFReadDirectory(TIFF* tif) if (!dircount) { TIFFErrorExt(tif->tif_clientdata,module, - "Failed to read directory at offset " TIFF_UINT64_FORMAT,nextdiroff); + "Failed to read directory at offset %" PRIu64, nextdiroff); return 0; } TIFFReadDirectoryCheckOrder(tif,dir,dircount); @@ -3612,11 +3611,11 @@ TIFFReadDirectory(TIFF* tif) */ { TIFFDirEntry* ma; - uint16 mb; + uint16_t mb; for (ma=dir, mb=0; mb<dircount; ma++, mb++) { TIFFDirEntry* na; - uint16 nb; + uint16_t nb; for (na=ma+1, nb=mb+1; nb<dircount; na++, nb++) { if (ma->tdir_tag == na->tdir_tag) { @@ -3673,7 +3672,7 @@ TIFFReadDirectory(TIFF* tif) * this, we accept the tag if one value is supplied with either * count. */ - uint16 value; + uint16_t value; enum TIFFReadDirEntryErr err; err=TIFFReadDirEntryShort(tif,dp,&value); if (err==TIFFReadDirEntryErrCount) @@ -3703,7 +3702,7 @@ TIFFReadDirectory(TIFF* tif) if (fii == FAILED_FII) { TIFFWarningExt(tif->tif_clientdata, module, - "Unknown field with tag %d (0x%x) encountered", + "Unknown field with tag %"PRIu16" (0x%"PRIx16") encountered", dp->tdir_tag,dp->tdir_tag); /* the following knowingly leaks the anonymous field structure */ @@ -3714,7 +3713,7 @@ TIFFReadDirectory(TIFF* tif) 1)) { TIFFWarningExt(tif->tif_clientdata, module, - "Registering anonymous field with tag %d (0x%x) failed", + "Registering anonymous field with tag %"PRIu16" (0x%"PRIx16") failed", dp->tdir_tag, dp->tdir_tag); dp->tdir_ignore = TRUE; @@ -3863,7 +3862,7 @@ TIFFReadDirectory(TIFF* tif) * too. */ { - uint16 value; + uint16_t value; enum TIFFReadDirEntryErr err; err=TIFFReadDirEntryShort(tif,dp,&value); if (err==TIFFReadDirEntryErrCount) @@ -3886,9 +3885,9 @@ TIFFReadDirectory(TIFF* tif) double *data = NULL; enum TIFFReadDirEntryErr err; - uint32 saved_flags; + uint32_t saved_flags; int m; - if (dp->tdir_count != (uint64)tif->tif_dir.td_samplesperpixel) + if (dp->tdir_count != (uint64_t)tif->tif_dir.td_samplesperpixel) err = TIFFReadDirEntryErrCount; else err = TIFFReadDirEntryDoubleArray(tif, dp, &data); @@ -3961,10 +3960,10 @@ TIFFReadDirectory(TIFF* tif) case TIFFTAG_TRANSFERFUNCTION: { enum TIFFReadDirEntryErr err; - uint32 countpersample; - uint32 countrequired; - uint32 incrementpersample; - uint16* value=NULL; + uint32_t countpersample; + uint32_t countrequired; + uint32_t incrementpersample; + uint16_t* value=NULL; /* It would be dangerous to instantiate those tag values */ /* since if td_bitspersample has not yet been read (due to */ /* unordered tags), it could be read afterwards with a */ @@ -3985,13 +3984,13 @@ TIFFReadDirectory(TIFF* tif) { fip = TIFFFieldWithTag(tif,dp->tdir_tag); TIFFWarningExt(tif->tif_clientdata,module, - "Ignoring %s because BitsPerSample=%d>24", + "Ignoring %s because BitsPerSample=%"PRIu16">24", fip ? fip->field_name : "unknown tagname", tif->tif_dir.td_bitspersample); continue; } countpersample=(1U<<tif->tif_dir.td_bitspersample); - if ((dp->tdir_tag==TIFFTAG_TRANSFERFUNCTION)&&(dp->tdir_count==(uint64)countpersample)) + if ((dp->tdir_tag==TIFFTAG_TRANSFERFUNCTION)&&(dp->tdir_count==(uint64_t)countpersample)) { countrequired=countpersample; incrementpersample=0; @@ -4001,7 +4000,7 @@ TIFFReadDirectory(TIFF* tif) countrequired=3*countpersample; incrementpersample=countpersample; } - if (dp->tdir_count!=(uint64)countrequired) + if (dp->tdir_count!=(uint64_t)countrequired) err=TIFFReadDirEntryErrCount; else err=TIFFReadDirEntryShortArray(tif,dp,&value); @@ -4020,8 +4019,8 @@ TIFFReadDirectory(TIFF* tif) /* BEGIN REV 4.0 COMPATIBILITY */ case TIFFTAG_OSUBFILETYPE: { - uint16 valueo; - uint32 value; + uint16_t valueo; + uint32_t value; if (TIFFReadDirEntryShort(tif,dp,&valueo)==TIFFReadDirEntryErrOk) { switch (valueo) @@ -4154,26 +4153,27 @@ TIFFReadDirectory(TIFF* tif) */ color_channels = _TIFFGetMaxColorChannels(tif->tif_dir.td_photometric); if (color_channels && tif->tif_dir.td_samplesperpixel - tif->tif_dir.td_extrasamples > color_channels) { - uint16 old_extrasamples; - uint16 *new_sampleinfo; + uint16_t old_extrasamples; + uint16_t *new_sampleinfo; TIFFWarningExt(tif->tif_clientdata,module, "Sum of Photometric type-related " "color channels and ExtraSamples doesn't match SamplesPerPixel. " "Defining non-color channels as ExtraSamples."); old_extrasamples = tif->tif_dir.td_extrasamples; - tif->tif_dir.td_extrasamples = (uint16) (tif->tif_dir.td_samplesperpixel - color_channels); + tif->tif_dir.td_extrasamples = (uint16_t) (tif->tif_dir.td_samplesperpixel - color_channels); // sampleinfo should contain information relative to these new extra samples - new_sampleinfo = (uint16*) _TIFFcalloc(tif->tif_dir.td_extrasamples, sizeof(uint16)); + new_sampleinfo = (uint16_t*) _TIFFcalloc(tif->tif_dir.td_extrasamples, sizeof(uint16_t)); if (!new_sampleinfo) { TIFFErrorExt(tif->tif_clientdata, module, "Failed to allocate memory for " - "temporary new sampleinfo array (%d 16 bit elements)", + "temporary new sampleinfo array " + "(%"PRIu16" 16 bit elements)", tif->tif_dir.td_extrasamples); goto bad; } - memcpy(new_sampleinfo, tif->tif_dir.td_sampleinfo, old_extrasamples * sizeof(uint16)); + memcpy(new_sampleinfo, tif->tif_dir.td_sampleinfo, old_extrasamples * sizeof(uint16_t)); _TIFFsetShortArray(&tif->tif_dir.td_sampleinfo, new_sampleinfo, tif->tif_dir.td_extrasamples); _TIFFfree(new_sampleinfo); } @@ -4211,7 +4211,7 @@ TIFFReadDirectory(TIFF* tif) if ((tif->tif_dir.td_planarconfig == PLANARCONFIG_CONTIG && tif->tif_dir.td_nstrips > 1) || (tif->tif_dir.td_planarconfig == PLANARCONFIG_SEPARATE && - tif->tif_dir.td_nstrips != (uint32)tif->tif_dir.td_samplesperpixel)) { + tif->tif_dir.td_nstrips != (uint32_t)tif->tif_dir.td_samplesperpixel)) { MissingRequired(tif, "StripByteCounts"); goto bad; } @@ -4268,7 +4268,7 @@ TIFFReadDirectory(TIFF* tif) if (tif->tif_dir.td_bitspersample>=16) tif->tif_dir.td_maxsamplevalue=0xFFFF; else - tif->tif_dir.td_maxsamplevalue = (uint16)((1L<<tif->tif_dir.td_bitspersample)-1); + tif->tif_dir.td_maxsamplevalue = (uint16_t)((1L << tif->tif_dir.td_bitspersample) - 1); } #ifdef STRIPBYTECOUNTSORTED_UNUSED @@ -4278,7 +4278,7 @@ TIFFReadDirectory(TIFF* tif) * function in tif_write.c. */ if (!(tif->tif_flags&TIFF_DEFERSTRILELOAD) && tif->tif_dir.td_nstrips > 1) { - uint32 strip; + uint32_t strip; tif->tif_dir.td_stripbytecountsorted = 1; for (strip = 1; strip < tif->tif_dir.td_nstrips; strip++) { @@ -4333,10 +4333,10 @@ TIFFReadDirectory(TIFF* tif) /* * Reinitialize i/o since we are starting on a new directory. */ - tif->tif_row = (uint32) -1; - tif->tif_curstrip = (uint32) -1; - tif->tif_col = (uint32) -1; - tif->tif_curtile = (uint32) -1; + tif->tif_row = (uint32_t) -1; + tif->tif_curstrip = (uint32_t) -1; + tif->tif_col = (uint32_t) -1; + tif->tif_curtile = (uint32_t) -1; tif->tif_tilesize = (tmsize_t) -1; tif->tif_scanlinesize = TIFFScanlineSize(tif); @@ -4368,11 +4368,11 @@ bad: } static void -TIFFReadDirectoryCheckOrder(TIFF* tif, TIFFDirEntry* dir, uint16 dircount) +TIFFReadDirectoryCheckOrder(TIFF* tif, TIFFDirEntry* dir, uint16_t dircount) { static const char module[] = "TIFFReadDirectoryCheckOrder"; - uint16 m; - uint16 n; + uint16_t m; + uint16_t n; TIFFDirEntry* o; m=0; for (n=0, o=dir; n<dircount; n++, o++) @@ -4388,10 +4388,10 @@ TIFFReadDirectoryCheckOrder(TIFF* tif, TIFFDirEntry* dir, uint16 dircount) } static TIFFDirEntry* -TIFFReadDirectoryFindEntry(TIFF* tif, TIFFDirEntry* dir, uint16 dircount, uint16 tagid) +TIFFReadDirectoryFindEntry(TIFF* tif, TIFFDirEntry* dir, uint16_t dircount, uint16_t tagid) { TIFFDirEntry* m; - uint16 n; + uint16_t n; (void) tif; for (m=dir, n=0; n<dircount; m++, n++) { @@ -4402,11 +4402,11 @@ TIFFReadDirectoryFindEntry(TIFF* tif, TIFFDirEntry* dir, uint16 dircount, uint16 } static void -TIFFReadDirectoryFindFieldInfo(TIFF* tif, uint16 tagid, uint32* fii) +TIFFReadDirectoryFindFieldInfo(TIFF* tif, uint16_t tagid, uint32_t* fii) { - int32 ma,mb,mc; + int32_t ma,mb,mc; ma=-1; - mc=(int32)tif->tif_nfields; + mc=(int32_t)tif->tif_nfields; while (1) { if (ma+1==mc) @@ -4415,9 +4415,9 @@ TIFFReadDirectoryFindFieldInfo(TIFF* tif, uint16 tagid, uint32* fii) return; } mb=(ma+mc)/2; - if (tif->tif_fields[mb]->field_tag==(uint32)tagid) + if (tif->tif_fields[mb]->field_tag==(uint32_t)tagid) break; - if (tif->tif_fields[mb]->field_tag<(uint32)tagid) + if (tif->tif_fields[mb]->field_tag<(uint32_t)tagid) ma=mb; else mc=mb; @@ -4426,7 +4426,7 @@ TIFFReadDirectoryFindFieldInfo(TIFF* tif, uint16 tagid, uint32* fii) { if (mb==0) break; - if (tif->tif_fields[mb-1]->field_tag!=(uint32)tagid) + if (tif->tif_fields[mb-1]->field_tag!=(uint32_t)tagid) break; mb--; } @@ -4443,18 +4443,18 @@ TIFFReadCustomDirectory(TIFF* tif, toff_t diroff, { static const char module[] = "TIFFReadCustomDirectory"; TIFFDirEntry* dir; - uint16 dircount; + uint16_t dircount; TIFFDirEntry* dp; - uint16 di; + uint16_t di; const TIFFField* fip; - uint32 fii; + uint32_t fii; (*tif->tif_cleanup)(tif); /* cleanup any previous compression state */ _TIFFSetupFields(tif, infoarray); dircount=TIFFFetchDirectory(tif,diroff,&dir,NULL); if (!dircount) { TIFFErrorExt(tif->tif_clientdata,module, - "Failed to read custom directory at offset " TIFF_UINT64_FORMAT,diroff); + "Failed to read custom directory at offset %" PRIu64,diroff); return 0; } TIFFFreeDirectory(tif); @@ -4466,14 +4466,14 @@ TIFFReadCustomDirectory(TIFF* tif, toff_t diroff, if (fii == FAILED_FII) { TIFFWarningExt(tif->tif_clientdata, module, - "Unknown field with tag %d (0x%x) encountered", + "Unknown field with tag %"PRIu16" (0x%"PRIx16") encountered", dp->tdir_tag, dp->tdir_tag); if (!_TIFFMergeFields(tif, _TIFFCreateAnonField(tif, dp->tdir_tag, (TIFFDataType) dp->tdir_type), 1)) { TIFFWarningExt(tif->tif_clientdata, module, - "Registering anonymous field with tag %d (0x%x) failed", + "Registering anonymous field with tag %"PRIu16" (0x%"PRIx16") failed", dp->tdir_tag, dp->tdir_tag); dp->tdir_ignore = TRUE; } else { @@ -4493,7 +4493,7 @@ TIFFReadCustomDirectory(TIFF* tif, toff_t diroff, { fii++; if ((fii==tif->tif_nfields)|| - (tif->tif_fields[fii]->field_tag!=(uint32)dp->tdir_tag)) + (tif->tif_fields[fii]->field_tag!=(uint32_t)dp->tdir_tag)) { fii=0xFFFF; break; @@ -4503,7 +4503,7 @@ TIFFReadCustomDirectory(TIFF* tif, toff_t diroff, if (fii==0xFFFF) { TIFFWarningExt(tif->tif_clientdata, module, - "Wrong data type %d for \"%s\"; tag ignored", + "Wrong data type %"PRIu16" for \"%s\"; tag ignored", dp->tdir_type,fip->field_name); dp->tdir_ignore = TRUE; } @@ -4513,11 +4513,11 @@ TIFFReadCustomDirectory(TIFF* tif, toff_t diroff, if ((fip->field_readcount!=TIFF_VARIABLE)&& (fip->field_readcount!=TIFF_VARIABLE2)) { - uint32 expected; + uint32_t expected; if (fip->field_readcount==TIFF_SPP) - expected=(uint32)tif->tif_dir.td_samplesperpixel; + expected=(uint32_t)tif->tif_dir.td_samplesperpixel; else - expected=(uint32)fip->field_readcount; + expected=(uint32_t)fip->field_readcount; if (!CheckDirCount(tif,dp,expected)) dp->tdir_ignore = TRUE; } @@ -4565,13 +4565,13 @@ TIFFReadGPSDirectory(TIFF* tif, toff_t diroff) } static int -EstimateStripByteCounts(TIFF* tif, TIFFDirEntry* dir, uint16 dircount) +EstimateStripByteCounts(TIFF* tif, TIFFDirEntry* dir, uint16_t dircount) { static const char module[] = "EstimateStripByteCounts"; TIFFDirEntry *dp; TIFFDirectory *td = &tif->tif_dir; - uint32 strip; + uint32_t strip; /* Do not try to load stripbytecount as we will compute it */ if( !_TIFFFillStrilesInternal( tif, 0 ) ) @@ -4579,16 +4579,16 @@ EstimateStripByteCounts(TIFF* tif, TIFFDirEntry* dir, uint16 dircount) if (td->td_stripbytecount_p) _TIFFfree(td->td_stripbytecount_p); - td->td_stripbytecount_p = (uint64*) - _TIFFCheckMalloc(tif, td->td_nstrips, sizeof (uint64), + td->td_stripbytecount_p = (uint64_t*) + _TIFFCheckMalloc(tif, td->td_nstrips, sizeof (uint64_t), "for \"StripByteCounts\" array"); if( td->td_stripbytecount_p == NULL ) return -1; if (td->td_compression != COMPRESSION_NONE) { - uint64 space; - uint64 filesize; - uint16 n; + uint64_t space; + uint64_t filesize; + uint16_t n; filesize = TIFFGetFileSize(tif); if (!(tif->tif_flags&TIFF_BIGTIFF)) space=sizeof(TIFFHeaderClassic)+2+dircount*12+4; @@ -4597,18 +4597,18 @@ EstimateStripByteCounts(TIFF* tif, TIFFDirEntry* dir, uint16 dircount) /* calculate amount of space used by indirect values */ for (dp = dir, n = dircount; n > 0; n--, dp++) { - uint32 typewidth; - uint64 datasize; + uint32_t typewidth; + uint64_t datasize; typewidth = TIFFDataWidth((TIFFDataType) dp->tdir_type); if (typewidth == 0) { TIFFErrorExt(tif->tif_clientdata, module, - "Cannot determine size of unknown tag type %d", + "Cannot determine size of unknown tag type %"PRIu16, dp->tdir_type); return -1; } - if( dp->tdir_count > TIFF_UINT64_MAX / typewidth ) + if( dp->tdir_count > UINT64_MAX / typewidth ) return -1; - datasize=(uint64)typewidth*dp->tdir_count; + datasize= (uint64_t)typewidth * dp->tdir_count; if (!(tif->tif_flags&TIFF_BIGTIFF)) { if (datasize<=4) @@ -4619,7 +4619,7 @@ EstimateStripByteCounts(TIFF* tif, TIFFDirEntry* dir, uint16 dircount) if (datasize<=8) datasize=0; } - if( space > TIFF_UINT64_MAX - datasize ) + if( space > UINT64_MAX - datasize ) return -1; space+=datasize; } @@ -4640,7 +4640,7 @@ EstimateStripByteCounts(TIFF* tif, TIFFDirEntry* dir, uint16 dircount) * of data in the strip and trim this number back accordingly. */ strip--; - if (td->td_stripoffset_p[strip] > TIFF_UINT64_MAX - td->td_stripbytecount_p[strip]) + if (td->td_stripoffset_p[strip] > UINT64_MAX - td->td_stripbytecount_p[strip]) return -1; if (td->td_stripoffset_p[strip]+td->td_stripbytecount_p[strip] > filesize) { if( td->td_stripoffset_p[strip] >= filesize ) { @@ -4651,16 +4651,16 @@ EstimateStripByteCounts(TIFF* tif, TIFFDirEntry* dir, uint16 dircount) } } } else if (isTiled(tif)) { - uint64 bytespertile = TIFFTileSize64(tif); + uint64_t bytespertile = TIFFTileSize64(tif); for (strip = 0; strip < td->td_nstrips; strip++) td->td_stripbytecount_p[strip] = bytespertile; } else { - uint64 rowbytes = TIFFScanlineSize64(tif); - uint32 rowsperstrip = td->td_imagelength/td->td_stripsperimage; + uint64_t rowbytes = TIFFScanlineSize64(tif); + uint32_t rowsperstrip = td->td_imagelength / td->td_stripsperimage; for (strip = 0; strip < td->td_nstrips; strip++) { - if( rowbytes > 0 && rowsperstrip > TIFF_UINT64_MAX / rowbytes ) + if( rowbytes > 0 && rowsperstrip > UINT64_MAX / rowbytes ) return -1; td->td_stripbytecount_p[strip] = rowbytes * rowsperstrip; } @@ -4688,9 +4688,9 @@ MissingRequired(TIFF* tif, const char* tagname) * seen directories and check every IFD offset against that list. */ static int -TIFFCheckDirOffset(TIFF* tif, uint64 diroff) +TIFFCheckDirOffset(TIFF* tif, uint64_t diroff) { - uint16 n; + uint16_t n; if (diroff == 0) /* no more directories */ return 0; @@ -4708,14 +4708,14 @@ TIFFCheckDirOffset(TIFF* tif, uint64 diroff) tif->tif_dirnumber++; if (tif->tif_dirlist == NULL || tif->tif_dirnumber > tif->tif_dirlistsize) { - uint64* new_dirlist; + uint64_t* new_dirlist; /* * XXX: Reduce memory allocation granularity of the dirlist * array. */ - new_dirlist = (uint64*)_TIFFCheckRealloc(tif, tif->tif_dirlist, - tif->tif_dirnumber, 2 * sizeof(uint64), "for IFD list"); + new_dirlist = (uint64_t*)_TIFFCheckRealloc(tif, tif->tif_dirlist, + tif->tif_dirnumber, 2 * sizeof(uint64_t), "for IFD list"); if (!new_dirlist) return 0; if( tif->tif_dirnumber >= 32768 ) @@ -4735,19 +4735,19 @@ TIFFCheckDirOffset(TIFF* tif, uint64 diroff) * caller is expected to skip/ignore the tag if there is a mismatch. */ static int -CheckDirCount(TIFF* tif, TIFFDirEntry* dir, uint32 count) +CheckDirCount(TIFF* tif, TIFFDirEntry* dir, uint32_t count) { - if ((uint64)count > dir->tdir_count) { + if ((uint64_t)count > dir->tdir_count) { const TIFFField* fip = TIFFFieldWithTag(tif, dir->tdir_tag); TIFFWarningExt(tif->tif_clientdata, tif->tif_name, - "incorrect count for field \"%s\" (" TIFF_UINT64_FORMAT ", expecting %u); tag ignored", + "incorrect count for field \"%s\" (%" PRIu64 ", expecting %"PRIu32"); tag ignored", fip ? fip->field_name : "unknown tagname", dir->tdir_count, count); return (0); - } else if ((uint64)count < dir->tdir_count) { + } else if ((uint64_t)count < dir->tdir_count) { const TIFFField* fip = TIFFFieldWithTag(tif, dir->tdir_tag); TIFFWarningExt(tif->tif_clientdata, tif->tif_name, - "incorrect count for field \"%s\" (" TIFF_UINT64_FORMAT ", expecting %u); tag trimmed", + "incorrect count for field \"%s\" (%" PRIu64 ", expecting %"PRIu32"); tag trimmed", fip ? fip->field_name : "unknown tagname", dir->tdir_count, count); dir->tdir_count = count; @@ -4761,19 +4761,19 @@ CheckDirCount(TIFF* tif, TIFFDirEntry* dir, uint32 count) * nextdiroff variable has been specified, read it too. Function returns a * number of fields in the directory or 0 if failed. */ -static uint16 -TIFFFetchDirectory(TIFF* tif, uint64 diroff, TIFFDirEntry** pdir, - uint64 *nextdiroff) +static uint16_t +TIFFFetchDirectory(TIFF* tif, uint64_t diroff, TIFFDirEntry** pdir, + uint64_t *nextdiroff) { static const char module[] = "TIFFFetchDirectory"; void* origdir; - uint16 dircount16; - uint32 dirsize; + uint16_t dircount16; + uint32_t dirsize; TIFFDirEntry* dir; - uint8* ma; + uint8_t* ma; TIFFDirEntry* mb; - uint16 n; + uint16_t n; assert(pdir); @@ -4789,7 +4789,7 @@ TIFFFetchDirectory(TIFF* tif, uint64 diroff, TIFFDirEntry** pdir, } if (!(tif->tif_flags&TIFF_BIGTIFF)) { - if (!ReadOK(tif, &dircount16, sizeof (uint16))) { + if (!ReadOK(tif, &dircount16, sizeof (uint16_t))) { TIFFErrorExt(tif->tif_clientdata, module, "%s: Can not read TIFF directory count", tif->tif_name); @@ -4805,8 +4805,8 @@ TIFFFetchDirectory(TIFF* tif, uint64 diroff, TIFFDirEntry** pdir, } dirsize = 12; } else { - uint64 dircount64; - if (!ReadOK(tif, &dircount64, sizeof (uint64))) { + uint64_t dircount64; + if (!ReadOK(tif, &dircount64, sizeof (uint64_t))) { TIFFErrorExt(tif->tif_clientdata, module, "%s: Can not read TIFF directory count", tif->tif_name); @@ -4820,7 +4820,7 @@ TIFFFetchDirectory(TIFF* tif, uint64 diroff, TIFFDirEntry** pdir, "Sanity check on directory count failed, this is probably not a valid IFD offset"); return 0; } - dircount16 = (uint16)dircount64; + dircount16 = (uint16_t)dircount64; dirsize = 20; } origdir = _TIFFCheckMalloc(tif, dircount16, @@ -4842,14 +4842,14 @@ TIFFFetchDirectory(TIFF* tif, uint64 diroff, TIFFDirEntry** pdir, { if (!(tif->tif_flags&TIFF_BIGTIFF)) { - uint32 nextdiroff32; - if (!ReadOK(tif, &nextdiroff32, sizeof(uint32))) + uint32_t nextdiroff32; + if (!ReadOK(tif, &nextdiroff32, sizeof(uint32_t))) nextdiroff32 = 0; if (tif->tif_flags&TIFF_SWAB) TIFFSwabLong(&nextdiroff32); *nextdiroff=nextdiroff32; } else { - if (!ReadOK(tif, nextdiroff, sizeof(uint64))) + if (!ReadOK(tif, nextdiroff, sizeof(uint64_t))) *nextdiroff = 0; if (tif->tif_flags&TIFF_SWAB) TIFFSwabLong8(nextdiroff); @@ -4858,7 +4858,7 @@ TIFFFetchDirectory(TIFF* tif, uint64 diroff, TIFFDirEntry** pdir, } else { tmsize_t m; tmsize_t off; - if (tif->tif_diroff > (uint64)TIFF_INT64_MAX) + if (tif->tif_diroff > (uint64_t)INT64_MAX) { TIFFErrorExt(tif->tif_clientdata,module,"Can not read TIFF directory count"); return(0); @@ -4870,22 +4870,22 @@ TIFFFetchDirectory(TIFF* tif, uint64 diroff, TIFFDirEntry** pdir, * otherwise a very high offset may cause an OOB read and * crash the client. Make two comparisons instead of * - * off + sizeof(uint16) > tif->tif_size + * off + sizeof(uint16_t) > tif->tif_size * * to avoid overflow. */ if (!(tif->tif_flags&TIFF_BIGTIFF)) { - m=off+sizeof(uint16); - if ((m<off)||(m<(tmsize_t)sizeof(uint16))||(m>tif->tif_size)) { + m=off+sizeof(uint16_t); + if ((m<off) || (m<(tmsize_t)sizeof(uint16_t)) || (m > tif->tif_size)) { TIFFErrorExt(tif->tif_clientdata, module, "Can not read TIFF directory count"); return 0; } else { _TIFFmemcpy(&dircount16, tif->tif_base + off, - sizeof(uint16)); + sizeof(uint16_t)); } - off += sizeof (uint16); + off += sizeof (uint16_t); if (tif->tif_flags & TIFF_SWAB) TIFFSwabShort(&dircount16); if (dircount16>4096) @@ -4898,17 +4898,17 @@ TIFFFetchDirectory(TIFF* tif, uint64 diroff, TIFFDirEntry** pdir, } else { - uint64 dircount64; - m=off+sizeof(uint64); - if ((m<off)||(m<(tmsize_t)sizeof(uint64))||(m>tif->tif_size)) { + uint64_t dircount64; + m=off+sizeof(uint64_t); + if ((m<off) || (m<(tmsize_t)sizeof(uint64_t)) || (m > tif->tif_size)) { TIFFErrorExt(tif->tif_clientdata, module, "Can not read TIFF directory count"); return 0; } else { _TIFFmemcpy(&dircount64, tif->tif_base + off, - sizeof(uint64)); + sizeof(uint64_t)); } - off += sizeof (uint64); + off += sizeof (uint64_t); if (tif->tif_flags & TIFF_SWAB) TIFFSwabLong8(&dircount64); if (dircount64>4096) @@ -4917,7 +4917,7 @@ TIFFFetchDirectory(TIFF* tif, uint64 diroff, TIFFDirEntry** pdir, "Sanity check on directory count failed, this is probably not a valid IFD offset"); return 0; } - dircount16 = (uint16)dircount64; + dircount16 = (uint16_t)dircount64; dirsize = 20; } if (dircount16 == 0 ) @@ -4945,25 +4945,25 @@ TIFFFetchDirectory(TIFF* tif, uint64 diroff, TIFFDirEntry** pdir, off += dircount16 * dirsize; if (!(tif->tif_flags&TIFF_BIGTIFF)) { - uint32 nextdiroff32; - m=off+sizeof(uint32); - if ((m<off)||(m<(tmsize_t)sizeof(uint32))||(m>tif->tif_size)) + uint32_t nextdiroff32; + m=off+sizeof(uint32_t); + if ((m<off) || (m<(tmsize_t)sizeof(uint32_t)) || (m > tif->tif_size)) nextdiroff32 = 0; else _TIFFmemcpy(&nextdiroff32, tif->tif_base + off, - sizeof (uint32)); + sizeof (uint32_t)); if (tif->tif_flags&TIFF_SWAB) TIFFSwabLong(&nextdiroff32); *nextdiroff = nextdiroff32; } else { - m=off+sizeof(uint64); - if ((m<off)||(m<(tmsize_t)sizeof(uint64))||(m>tif->tif_size)) + m=off+sizeof(uint64_t); + if ((m<off) || (m<(tmsize_t)sizeof(uint64_t)) || (m > tif->tif_size)) *nextdiroff = 0; else _TIFFmemcpy(nextdiroff, tif->tif_base + off, - sizeof (uint64)); + sizeof (uint64_t)); if (tif->tif_flags&TIFF_SWAB) TIFFSwabLong8(nextdiroff); } @@ -4977,37 +4977,37 @@ TIFFFetchDirectory(TIFF* tif, uint64 diroff, TIFFDirEntry** pdir, _TIFFfree(origdir); return 0; } - ma=(uint8*)origdir; + ma=(uint8_t*)origdir; mb=dir; for (n=0; n<dircount16; n++) { mb->tdir_ignore = FALSE; if (tif->tif_flags&TIFF_SWAB) - TIFFSwabShort((uint16*)ma); - mb->tdir_tag=*(uint16*)ma; - ma+=sizeof(uint16); + TIFFSwabShort((uint16_t*)ma); + mb->tdir_tag=*(uint16_t*)ma; + ma+=sizeof(uint16_t); if (tif->tif_flags&TIFF_SWAB) - TIFFSwabShort((uint16*)ma); - mb->tdir_type=*(uint16*)ma; - ma+=sizeof(uint16); + TIFFSwabShort((uint16_t*)ma); + mb->tdir_type=*(uint16_t*)ma; + ma+=sizeof(uint16_t); if (!(tif->tif_flags&TIFF_BIGTIFF)) { if (tif->tif_flags&TIFF_SWAB) - TIFFSwabLong((uint32*)ma); - mb->tdir_count=(uint64)(*(uint32*)ma); - ma+=sizeof(uint32); + TIFFSwabLong((uint32_t*)ma); + mb->tdir_count=(uint64_t)(*(uint32_t*)ma); + ma+=sizeof(uint32_t); mb->tdir_offset.toff_long8=0; - *(uint32*)(&mb->tdir_offset)=*(uint32*)ma; - ma+=sizeof(uint32); + *(uint32_t*)(&mb->tdir_offset)=*(uint32_t*)ma; + ma+=sizeof(uint32_t); } else { if (tif->tif_flags&TIFF_SWAB) - TIFFSwabLong8((uint64*)ma); + TIFFSwabLong8((uint64_t*)ma); mb->tdir_count=TIFFReadUInt64(ma); - ma+=sizeof(uint64); + ma+=sizeof(uint64_t); mb->tdir_offset.toff_long8=TIFFReadUInt64(ma); - ma+=sizeof(uint64); + ma+=sizeof(uint64_t); } mb++; } @@ -5024,13 +5024,13 @@ TIFFFetchNormalTag(TIFF* tif, TIFFDirEntry* dp, int recover) { static const char module[] = "TIFFFetchNormalTag"; enum TIFFReadDirEntryErr err; - uint32 fii; + uint32_t fii; const TIFFField* fip = NULL; TIFFReadDirectoryFindFieldInfo(tif,dp->tdir_tag,&fii); if( fii == FAILED_FII ) { TIFFErrorExt(tif->tif_clientdata, "TIFFFetchNormalTag", - "No definition found for tag %d", + "No definition found for tag %"PRIu16, dp->tdir_tag); return 0; } @@ -5045,17 +5045,17 @@ TIFFFetchNormalTag(TIFF* tif, TIFFDirEntry* dp, int recover) break; case TIFF_SETGET_ASCII: { - uint8* data; + uint8_t* data; assert(fip->field_passcount==0); err=TIFFReadDirEntryByteArray(tif,dp,&data); if (err==TIFFReadDirEntryErrOk) { - uint32 mb = 0; + uint32_t mb = 0; int n; if (data != NULL) { - uint8* ma = data; - while (mb<(uint32)dp->tdir_count) + uint8_t* ma = data; + while (mb<(uint32_t)dp->tdir_count) { if (*ma==0) break; @@ -5063,24 +5063,24 @@ TIFFFetchNormalTag(TIFF* tif, TIFFDirEntry* dp, int recover) mb++; } } - if (mb+1<(uint32)dp->tdir_count) + if (mb+1<(uint32_t)dp->tdir_count) TIFFWarningExt(tif->tif_clientdata,module,"ASCII value for tag \"%s\" contains null byte in value; value incorrectly truncated during reading due to implementation limitations",fip->field_name); - else if (mb+1>(uint32)dp->tdir_count) + else if (mb+1>(uint32_t)dp->tdir_count) { - uint8* o; + uint8_t* o; TIFFWarningExt(tif->tif_clientdata,module,"ASCII value for tag \"%s\" does not end in null byte",fip->field_name); - if ((uint32)dp->tdir_count+1!=dp->tdir_count+1) + if ((uint32_t)dp->tdir_count + 1 != dp->tdir_count + 1) o=NULL; else - o=_TIFFmalloc((uint32)dp->tdir_count+1); + o=_TIFFmalloc((uint32_t)dp->tdir_count + 1); if (o==NULL) { if (data!=NULL) _TIFFfree(data); return(0); } - _TIFFmemcpy(o,data,(uint32)dp->tdir_count); - o[(uint32)dp->tdir_count]=0; + _TIFFmemcpy(o,data,(uint32_t)dp->tdir_count); + o[(uint32_t)dp->tdir_count]=0; if (data!=0) _TIFFfree(data); data=o; @@ -5095,7 +5095,7 @@ TIFFFetchNormalTag(TIFF* tif, TIFFDirEntry* dp, int recover) break; case TIFF_SETGET_UINT8: { - uint8 data=0; + uint8_t data=0; assert(fip->field_readcount==1); assert(fip->field_passcount==0); err=TIFFReadDirEntryByte(tif,dp,&data); @@ -5108,7 +5108,7 @@ TIFFFetchNormalTag(TIFF* tif, TIFFDirEntry* dp, int recover) break; case TIFF_SETGET_UINT16: { - uint16 data; + uint16_t data; assert(fip->field_readcount==1); assert(fip->field_passcount==0); err=TIFFReadDirEntryShort(tif,dp,&data); @@ -5121,7 +5121,7 @@ TIFFFetchNormalTag(TIFF* tif, TIFFDirEntry* dp, int recover) break; case TIFF_SETGET_UINT32: { - uint32 data; + uint32_t data; assert(fip->field_readcount==1); assert(fip->field_passcount==0); err=TIFFReadDirEntryLong(tif,dp,&data); @@ -5134,7 +5134,7 @@ TIFFFetchNormalTag(TIFF* tif, TIFFDirEntry* dp, int recover) break; case TIFF_SETGET_UINT64: { - uint64 data; + uint64_t data; assert(fip->field_readcount==1); assert(fip->field_passcount==0); err=TIFFReadDirEntryLong8(tif,dp,&data); @@ -5173,7 +5173,7 @@ TIFFFetchNormalTag(TIFF* tif, TIFFDirEntry* dp, int recover) break; case TIFF_SETGET_IFD8: { - uint64 data; + uint64_t data; assert(fip->field_readcount==1); assert(fip->field_passcount==0); err=TIFFReadDirEntryIfd8(tif,dp,&data); @@ -5186,13 +5186,13 @@ TIFFFetchNormalTag(TIFF* tif, TIFFDirEntry* dp, int recover) break; case TIFF_SETGET_UINT16_PAIR: { - uint16* data; + uint16_t* data; assert(fip->field_readcount==2); assert(fip->field_passcount==0); if (dp->tdir_count!=2) { TIFFWarningExt(tif->tif_clientdata,module, - "incorrect count for field \"%s\", expected 2, got %d", - fip->field_name,(int)dp->tdir_count); + "incorrect count for field \"%s\", expected 2, got %"PRIu64, + fip->field_name, dp->tdir_count); return(0); } err=TIFFReadDirEntryShortArray(tif,dp,&data); @@ -5209,13 +5209,13 @@ TIFFFetchNormalTag(TIFF* tif, TIFFDirEntry* dp, int recover) break; case TIFF_SETGET_C0_UINT8: { - uint8* data; + uint8_t* data; assert(fip->field_readcount>=1); assert(fip->field_passcount==0); - if (dp->tdir_count!=(uint64)fip->field_readcount) { + if (dp->tdir_count!=(uint64_t)fip->field_readcount) { TIFFWarningExt(tif->tif_clientdata,module, - "incorrect count for field \"%s\", expected %d, got %d", - fip->field_name,(int) fip->field_readcount, (int)dp->tdir_count); + "incorrect count for field \"%s\", expected %d, got %"PRIu64, + fip->field_name,(int) fip->field_readcount, dp->tdir_count); return 0; } else @@ -5235,10 +5235,10 @@ TIFFFetchNormalTag(TIFF* tif, TIFFDirEntry* dp, int recover) break; case TIFF_SETGET_C0_UINT16: { - uint16* data; + uint16_t* data; assert(fip->field_readcount>=1); assert(fip->field_passcount==0); - if (dp->tdir_count!=(uint64)fip->field_readcount) + if (dp->tdir_count!=(uint64_t)fip->field_readcount) /* corrupt file */; else { @@ -5257,10 +5257,10 @@ TIFFFetchNormalTag(TIFF* tif, TIFFDirEntry* dp, int recover) break; case TIFF_SETGET_C0_UINT32: { - uint32* data; + uint32_t* data; assert(fip->field_readcount>=1); assert(fip->field_passcount==0); - if (dp->tdir_count!=(uint64)fip->field_readcount) + if (dp->tdir_count!=(uint64_t)fip->field_readcount) /* corrupt file */; else { @@ -5282,7 +5282,7 @@ TIFFFetchNormalTag(TIFF* tif, TIFFDirEntry* dp, int recover) float* data; assert(fip->field_readcount>=1); assert(fip->field_passcount==0); - if (dp->tdir_count!=(uint64)fip->field_readcount) + if (dp->tdir_count!=(uint64_t)fip->field_readcount) /* corrupt file */; else { @@ -5305,7 +5305,7 @@ TIFFFetchNormalTag(TIFF* tif, TIFFDirEntry* dp, int recover) double* data; assert(fip->field_readcount>=1); assert(fip->field_passcount==0); - if (dp->tdir_count!=(uint64)fip->field_readcount) + if (dp->tdir_count!=(uint64_t)fip->field_readcount) /* corrupt file */; else { @@ -5324,7 +5324,7 @@ TIFFFetchNormalTag(TIFF* tif, TIFFDirEntry* dp, int recover) break; case TIFF_SETGET_C16_ASCII: { - uint8* data; + uint8_t* data; assert(fip->field_readcount==TIFF_VARIABLE); assert(fip->field_passcount==1); if (dp->tdir_count>0xFFFF) @@ -5340,7 +5340,7 @@ TIFFFetchNormalTag(TIFF* tif, TIFFDirEntry* dp, int recover) TIFFWarningExt(tif->tif_clientdata,module,"ASCII value for tag \"%s\" does not end in null byte. Forcing it to be null",fip->field_name); data[dp->tdir_count-1] = '\0'; } - m=TIFFSetField(tif,dp->tdir_tag,(uint16)(dp->tdir_count),data); + m=TIFFSetField(tif, dp->tdir_tag, (uint16_t)(dp->tdir_count), data); if (data!=0) _TIFFfree(data); if (!m) @@ -5351,7 +5351,7 @@ TIFFFetchNormalTag(TIFF* tif, TIFFDirEntry* dp, int recover) break; case TIFF_SETGET_C16_UINT8: { - uint8* data; + uint8_t* data; assert(fip->field_readcount==TIFF_VARIABLE); assert(fip->field_passcount==1); if (dp->tdir_count>0xFFFF) @@ -5362,7 +5362,7 @@ TIFFFetchNormalTag(TIFF* tif, TIFFDirEntry* dp, int recover) if (err==TIFFReadDirEntryErrOk) { int m; - m=TIFFSetField(tif,dp->tdir_tag,(uint16)(dp->tdir_count),data); + m=TIFFSetField(tif, dp->tdir_tag, (uint16_t)(dp->tdir_count), data); if (data!=0) _TIFFfree(data); if (!m) @@ -5373,7 +5373,7 @@ TIFFFetchNormalTag(TIFF* tif, TIFFDirEntry* dp, int recover) break; case TIFF_SETGET_C16_UINT16: { - uint16* data; + uint16_t* data; assert(fip->field_readcount==TIFF_VARIABLE); assert(fip->field_passcount==1); if (dp->tdir_count>0xFFFF) @@ -5384,7 +5384,7 @@ TIFFFetchNormalTag(TIFF* tif, TIFFDirEntry* dp, int recover) if (err==TIFFReadDirEntryErrOk) { int m; - m=TIFFSetField(tif,dp->tdir_tag,(uint16)(dp->tdir_count),data); + m=TIFFSetField(tif, dp->tdir_tag, (uint16_t)(dp->tdir_count), data); if (data!=0) _TIFFfree(data); if (!m) @@ -5395,7 +5395,7 @@ TIFFFetchNormalTag(TIFF* tif, TIFFDirEntry* dp, int recover) break; case TIFF_SETGET_C16_UINT32: { - uint32* data; + uint32_t* data; assert(fip->field_readcount==TIFF_VARIABLE); assert(fip->field_passcount==1); if (dp->tdir_count>0xFFFF) @@ -5406,7 +5406,7 @@ TIFFFetchNormalTag(TIFF* tif, TIFFDirEntry* dp, int recover) if (err==TIFFReadDirEntryErrOk) { int m; - m=TIFFSetField(tif,dp->tdir_tag,(uint16)(dp->tdir_count),data); + m=TIFFSetField(tif, dp->tdir_tag, (uint16_t)(dp->tdir_count), data); if (data!=0) _TIFFfree(data); if (!m) @@ -5417,7 +5417,7 @@ TIFFFetchNormalTag(TIFF* tif, TIFFDirEntry* dp, int recover) break; case TIFF_SETGET_C16_UINT64: { - uint64* data; + uint64_t* data; assert(fip->field_readcount==TIFF_VARIABLE); assert(fip->field_passcount==1); if (dp->tdir_count>0xFFFF) @@ -5428,7 +5428,7 @@ TIFFFetchNormalTag(TIFF* tif, TIFFDirEntry* dp, int recover) if (err==TIFFReadDirEntryErrOk) { int m; - m=TIFFSetField(tif,dp->tdir_tag,(uint16)(dp->tdir_count),data); + m=TIFFSetField(tif, dp->tdir_tag, (uint16_t)(dp->tdir_count), data); if (data!=0) _TIFFfree(data); if (!m) @@ -5450,7 +5450,7 @@ TIFFFetchNormalTag(TIFF* tif, TIFFDirEntry* dp, int recover) if (err==TIFFReadDirEntryErrOk) { int m; - m=TIFFSetField(tif,dp->tdir_tag,(uint16)(dp->tdir_count),data); + m=TIFFSetField(tif, dp->tdir_tag, (uint16_t)(dp->tdir_count), data); if (data!=0) _TIFFfree(data); if (!m) @@ -5472,7 +5472,7 @@ TIFFFetchNormalTag(TIFF* tif, TIFFDirEntry* dp, int recover) if (err==TIFFReadDirEntryErrOk) { int m; - m=TIFFSetField(tif,dp->tdir_tag,(uint16)(dp->tdir_count),data); + m=TIFFSetField(tif, dp->tdir_tag, (uint16_t)(dp->tdir_count), data); if (data!=0) _TIFFfree(data); if (!m) @@ -5483,7 +5483,7 @@ TIFFFetchNormalTag(TIFF* tif, TIFFDirEntry* dp, int recover) break; case TIFF_SETGET_C16_IFD8: { - uint64* data; + uint64_t* data; assert(fip->field_readcount==TIFF_VARIABLE); assert(fip->field_passcount==1); if (dp->tdir_count>0xFFFF) @@ -5494,7 +5494,7 @@ TIFFFetchNormalTag(TIFF* tif, TIFFDirEntry* dp, int recover) if (err==TIFFReadDirEntryErrOk) { int m; - m=TIFFSetField(tif,dp->tdir_tag,(uint16)(dp->tdir_count),data); + m=TIFFSetField(tif, dp->tdir_tag, (uint16_t)(dp->tdir_count), data); if (data!=0) _TIFFfree(data); if (!m) @@ -5505,7 +5505,7 @@ TIFFFetchNormalTag(TIFF* tif, TIFFDirEntry* dp, int recover) break; case TIFF_SETGET_C32_ASCII: { - uint8* data; + uint8_t* data; assert(fip->field_readcount==TIFF_VARIABLE2); assert(fip->field_passcount==1); err=TIFFReadDirEntryByteArray(tif,dp,&data); @@ -5517,7 +5517,7 @@ TIFFFetchNormalTag(TIFF* tif, TIFFDirEntry* dp, int recover) TIFFWarningExt(tif->tif_clientdata,module,"ASCII value for tag \"%s\" does not end in null byte. Forcing it to be null",fip->field_name); data[dp->tdir_count-1] = '\0'; } - m=TIFFSetField(tif,dp->tdir_tag,(uint32)(dp->tdir_count),data); + m=TIFFSetField(tif, dp->tdir_tag, (uint32_t)(dp->tdir_count), data); if (data!=0) _TIFFfree(data); if (!m) @@ -5527,14 +5527,14 @@ TIFFFetchNormalTag(TIFF* tif, TIFFDirEntry* dp, int recover) break; case TIFF_SETGET_C32_UINT8: { - uint8* data; + uint8_t* data; assert(fip->field_readcount==TIFF_VARIABLE2); assert(fip->field_passcount==1); err=TIFFReadDirEntryByteArray(tif,dp,&data); if (err==TIFFReadDirEntryErrOk) { int m; - m=TIFFSetField(tif,dp->tdir_tag,(uint32)(dp->tdir_count),data); + m=TIFFSetField(tif, dp->tdir_tag, (uint32_t)(dp->tdir_count), data); if (data!=0) _TIFFfree(data); if (!m) @@ -5544,14 +5544,14 @@ TIFFFetchNormalTag(TIFF* tif, TIFFDirEntry* dp, int recover) break; case TIFF_SETGET_C32_SINT8: { - int8* data = NULL; + int8_t* data = NULL; assert(fip->field_readcount==TIFF_VARIABLE2); assert(fip->field_passcount==1); err=TIFFReadDirEntrySbyteArray(tif,dp,&data); if (err==TIFFReadDirEntryErrOk) { int m; - m=TIFFSetField(tif,dp->tdir_tag,(uint32)(dp->tdir_count),data); + m=TIFFSetField(tif, dp->tdir_tag, (uint32_t)(dp->tdir_count), data); if (data!=0) _TIFFfree(data); if (!m) @@ -5561,14 +5561,14 @@ TIFFFetchNormalTag(TIFF* tif, TIFFDirEntry* dp, int recover) break; case TIFF_SETGET_C32_UINT16: { - uint16* data; + uint16_t* data; assert(fip->field_readcount==TIFF_VARIABLE2); assert(fip->field_passcount==1); err=TIFFReadDirEntryShortArray(tif,dp,&data); if (err==TIFFReadDirEntryErrOk) { int m; - m=TIFFSetField(tif,dp->tdir_tag,(uint32)(dp->tdir_count),data); + m=TIFFSetField(tif, dp->tdir_tag, (uint32_t)(dp->tdir_count), data); if (data!=0) _TIFFfree(data); if (!m) @@ -5578,14 +5578,14 @@ TIFFFetchNormalTag(TIFF* tif, TIFFDirEntry* dp, int recover) break; case TIFF_SETGET_C32_SINT16: { - int16* data = NULL; + int16_t* data = NULL; assert(fip->field_readcount==TIFF_VARIABLE2); assert(fip->field_passcount==1); err=TIFFReadDirEntrySshortArray(tif,dp,&data); if (err==TIFFReadDirEntryErrOk) { int m; - m=TIFFSetField(tif,dp->tdir_tag,(uint32)(dp->tdir_count),data); + m=TIFFSetField(tif, dp->tdir_tag, (uint32_t)(dp->tdir_count), data); if (data!=0) _TIFFfree(data); if (!m) @@ -5595,14 +5595,14 @@ TIFFFetchNormalTag(TIFF* tif, TIFFDirEntry* dp, int recover) break; case TIFF_SETGET_C32_UINT32: { - uint32* data; + uint32_t* data; assert(fip->field_readcount==TIFF_VARIABLE2); assert(fip->field_passcount==1); err=TIFFReadDirEntryLongArray(tif,dp,&data); if (err==TIFFReadDirEntryErrOk) { int m; - m=TIFFSetField(tif,dp->tdir_tag,(uint32)(dp->tdir_count),data); + m=TIFFSetField(tif, dp->tdir_tag, (uint32_t)(dp->tdir_count), data); if (data!=0) _TIFFfree(data); if (!m) @@ -5612,14 +5612,14 @@ TIFFFetchNormalTag(TIFF* tif, TIFFDirEntry* dp, int recover) break; case TIFF_SETGET_C32_SINT32: { - int32* data = NULL; + int32_t* data = NULL; assert(fip->field_readcount==TIFF_VARIABLE2); assert(fip->field_passcount==1); err=TIFFReadDirEntrySlongArray(tif,dp,&data); if (err==TIFFReadDirEntryErrOk) { int m; - m=TIFFSetField(tif,dp->tdir_tag,(uint32)(dp->tdir_count),data); + m=TIFFSetField(tif, dp->tdir_tag, (uint32_t)(dp->tdir_count), data); if (data!=0) _TIFFfree(data); if (!m) @@ -5629,14 +5629,14 @@ TIFFFetchNormalTag(TIFF* tif, TIFFDirEntry* dp, int recover) break; case TIFF_SETGET_C32_UINT64: { - uint64* data; + uint64_t* data; assert(fip->field_readcount==TIFF_VARIABLE2); assert(fip->field_passcount==1); err=TIFFReadDirEntryLong8Array(tif,dp,&data); if (err==TIFFReadDirEntryErrOk) { int m; - m=TIFFSetField(tif,dp->tdir_tag,(uint32)(dp->tdir_count),data); + m=TIFFSetField(tif, dp->tdir_tag, (uint32_t)(dp->tdir_count), data); if (data!=0) _TIFFfree(data); if (!m) @@ -5646,14 +5646,14 @@ TIFFFetchNormalTag(TIFF* tif, TIFFDirEntry* dp, int recover) break; case TIFF_SETGET_C32_SINT64: { - int64* data = NULL; + int64_t* data = NULL; assert(fip->field_readcount==TIFF_VARIABLE2); assert(fip->field_passcount==1); err=TIFFReadDirEntrySlong8Array(tif,dp,&data); if (err==TIFFReadDirEntryErrOk) { int m; - m=TIFFSetField(tif,dp->tdir_tag,(uint32)(dp->tdir_count),data); + m=TIFFSetField(tif, dp->tdir_tag, (uint32_t)(dp->tdir_count), data); if (data!=0) _TIFFfree(data); if (!m) @@ -5670,7 +5670,7 @@ TIFFFetchNormalTag(TIFF* tif, TIFFDirEntry* dp, int recover) if (err==TIFFReadDirEntryErrOk) { int m; - m=TIFFSetField(tif,dp->tdir_tag,(uint32)(dp->tdir_count),data); + m=TIFFSetField(tif, dp->tdir_tag, (uint32_t)(dp->tdir_count), data); if (data!=0) _TIFFfree(data); if (!m) @@ -5687,7 +5687,7 @@ TIFFFetchNormalTag(TIFF* tif, TIFFDirEntry* dp, int recover) if (err==TIFFReadDirEntryErrOk) { int m; - m=TIFFSetField(tif,dp->tdir_tag,(uint32)(dp->tdir_count),data); + m=TIFFSetField(tif, dp->tdir_tag, (uint32_t)(dp->tdir_count), data); if (data!=0) _TIFFfree(data); if (!m) @@ -5697,14 +5697,14 @@ TIFFFetchNormalTag(TIFF* tif, TIFFDirEntry* dp, int recover) break; case TIFF_SETGET_C32_IFD8: { - uint64* data; + uint64_t* data; assert(fip->field_readcount==TIFF_VARIABLE2); assert(fip->field_passcount==1); err=TIFFReadDirEntryIfd8Array(tif,dp,&data); if (err==TIFFReadDirEntryErrOk) { int m; - m=TIFFSetField(tif,dp->tdir_tag,(uint32)(dp->tdir_count),data); + m=TIFFSetField(tif, dp->tdir_tag, (uint32_t)(dp->tdir_count), data); if (data!=0) _TIFFfree(data); if (!m) @@ -5729,11 +5729,11 @@ TIFFFetchNormalTag(TIFF* tif, TIFFDirEntry* dp, int recover) * While this routine says "strips", in fact it's also used for tiles. */ static int -TIFFFetchStripThing(TIFF* tif, TIFFDirEntry* dir, uint32 nstrips, uint64** lpp) +TIFFFetchStripThing(TIFF* tif, TIFFDirEntry* dir, uint32_t nstrips, uint64_t** lpp) { static const char module[] = "TIFFFetchStripThing"; enum TIFFReadDirEntryErr err; - uint64* data; + uint64_t* data; err=TIFFReadDirEntryLong8ArrayWithLimit(tif,dir,&data,nstrips); if (err!=TIFFReadDirEntryErrOk) { @@ -5741,14 +5741,14 @@ TIFFFetchStripThing(TIFF* tif, TIFFDirEntry* dir, uint32 nstrips, uint64** lpp) TIFFReadDirEntryOutputErr(tif,err,module,fip ? fip->field_name : "unknown tagname",0); return(0); } - if (dir->tdir_count<(uint64)nstrips) + if (dir->tdir_count<(uint64_t)nstrips) { - uint64* resizeddata; + uint64_t* resizeddata; const TIFFField* fip = TIFFFieldWithTag(tif,dir->tdir_tag); const char* pszMax = getenv("LIBTIFF_STRILE_ARRAY_MAX_RESIZE_COUNT"); - uint32 max_nstrips = 1000000; + uint32_t max_nstrips = 1000000; if( pszMax ) - max_nstrips = (uint32) atoi(pszMax); + max_nstrips = (uint32_t) atoi(pszMax); TIFFReadDirEntryOutputErr(tif,TIFFReadDirEntryErrCount, module, fip ? fip->field_name : "unknown tagname", @@ -5760,13 +5760,13 @@ TIFFFetchStripThing(TIFF* tif, TIFFDirEntry* dir, uint32 nstrips, uint64** lpp) return(0); } - resizeddata=(uint64*)_TIFFCheckMalloc(tif,nstrips,sizeof(uint64),"for strip array"); + resizeddata=(uint64_t*)_TIFFCheckMalloc(tif, nstrips, sizeof(uint64_t), "for strip array"); if (resizeddata==0) { _TIFFfree(data); return(0); } - _TIFFmemcpy(resizeddata,data,(uint32)dir->tdir_count*sizeof(uint64)); - _TIFFmemset(resizeddata+(uint32)dir->tdir_count,0,(nstrips-(uint32)dir->tdir_count)*sizeof(uint64)); + _TIFFmemcpy(resizeddata,data, (uint32_t)dir->tdir_count * sizeof(uint64_t)); + _TIFFmemset(resizeddata+(uint32_t)dir->tdir_count, 0, (nstrips - (uint32_t)dir->tdir_count) * sizeof(uint64_t)); _TIFFfree(data); data=resizeddata; } @@ -5785,8 +5785,8 @@ TIFFFetchSubjectDistance(TIFF* tif, TIFFDirEntry* dir) UInt64Aligned_t m; m.l=0; assert(sizeof(double)==8); - assert(sizeof(uint64)==8); - assert(sizeof(uint32)==4); + assert(sizeof(uint64_t) == 8); + assert(sizeof(uint32_t) == 4); if (dir->tdir_count!=1) err=TIFFReadDirEntryErrCount; else if (dir->tdir_type!=TIFF_RATIONAL) @@ -5795,8 +5795,8 @@ TIFFFetchSubjectDistance(TIFF* tif, TIFFDirEntry* dir) { if (!(tif->tif_flags&TIFF_BIGTIFF)) { - uint32 offset; - offset=*(uint32*)(&dir->tdir_offset); + uint32_t offset; + offset=*(uint32_t*)(&dir->tdir_offset); if (tif->tif_flags&TIFF_SWAB) TIFFSwabLong(&offset); err=TIFFReadDirEntryData(tif,offset,8,m.i); @@ -5832,32 +5832,32 @@ TIFFFetchSubjectDistance(TIFF* tif, TIFFDirEntry* dir) } } -static void allocChoppedUpStripArrays(TIFF* tif, uint32 nstrips, - uint64 stripbytes, uint32 rowsperstrip) +static void allocChoppedUpStripArrays(TIFF* tif, uint32_t nstrips, + uint64_t stripbytes, uint32_t rowsperstrip) { TIFFDirectory *td = &tif->tif_dir; - uint64 bytecount; - uint64 offset; - uint64 last_offset; - uint64 last_bytecount; - uint32 i; - uint64 *newcounts; - uint64 *newoffsets; + uint64_t bytecount; + uint64_t offset; + uint64_t last_offset; + uint64_t last_bytecount; + uint32_t i; + uint64_t *newcounts; + uint64_t *newoffsets; offset = TIFFGetStrileOffset(tif, 0); last_offset = TIFFGetStrileOffset(tif, td->td_nstrips-1); last_bytecount = TIFFGetStrileByteCount(tif, td->td_nstrips-1); - if( last_offset > TIFF_UINT64_MAX - last_bytecount || + if( last_offset > UINT64_MAX - last_bytecount || last_offset + last_bytecount < offset ) { return; } bytecount = last_offset + last_bytecount - offset; - newcounts = (uint64*) _TIFFCheckMalloc(tif, nstrips, sizeof (uint64), - "for chopped \"StripByteCounts\" array"); - newoffsets = (uint64*) _TIFFCheckMalloc(tif, nstrips, sizeof (uint64), - "for chopped \"StripOffsets\" array"); + newcounts = (uint64_t*) _TIFFCheckMalloc(tif, nstrips, sizeof (uint64_t), + "for chopped \"StripByteCounts\" array"); + newoffsets = (uint64_t*) _TIFFCheckMalloc(tif, nstrips, sizeof (uint64_t), + "for chopped \"StripOffsets\" array"); if (newcounts == NULL || newoffsets == NULL) { /* * Unable to allocate new strip information, give up and use @@ -5911,13 +5911,13 @@ static void ChopUpSingleUncompressedStrip(TIFF* tif) { register TIFFDirectory *td = &tif->tif_dir; - uint64 bytecount; - uint64 offset; - uint32 rowblock; - uint64 rowblockbytes; - uint64 stripbytes; - uint32 nstrips; - uint32 rowsperstrip; + uint64_t bytecount; + uint64_t offset; + uint32_t rowblock; + uint64_t rowblockbytes; + uint64_t stripbytes; + uint32_t nstrips; + uint32_t rowsperstrip; bytecount = TIFFGetStrileByteCount(tif, 0); /* On a newly created file, just re-opened to be filled, we */ @@ -5941,8 +5941,8 @@ ChopUpSingleUncompressedStrip(TIFF* tif) stripbytes = rowblockbytes; rowsperstrip = rowblock; } else if (rowblockbytes > 0 ) { - uint32 rowblocksperstrip; - rowblocksperstrip = (uint32) (STRIP_SIZE_DEFAULT / rowblockbytes); + uint32_t rowblocksperstrip; + rowblocksperstrip = (uint32_t) (STRIP_SIZE_DEFAULT / rowblockbytes); rowsperstrip = rowblocksperstrip * rowblock; stripbytes = rowblocksperstrip * rowblockbytes; } @@ -5981,14 +5981,14 @@ ChopUpSingleUncompressedStrip(TIFF* tif) static void TryChopUpUncompressedBigTiff( TIFF* tif ) { TIFFDirectory *td = &tif->tif_dir; - uint32 rowblock; - uint64 rowblockbytes; - uint32 i; - uint64 stripsize; - uint32 rowblocksperstrip; - uint32 rowsperstrip; - uint64 stripbytes; - uint32 nstrips; + uint32_t rowblock; + uint64_t rowblockbytes; + uint32_t i; + uint64_t stripsize; + uint32_t rowblocksperstrip; + uint32_t rowsperstrip; + uint64_t stripbytes; + uint32_t nstrips; stripsize = TIFFStripSize64(tif); @@ -6041,7 +6041,7 @@ static void TryChopUpUncompressedBigTiff( TIFF* tif ) } /* Aim for 512 MB strips (that will still be manageable by 32 bit builds */ - rowblocksperstrip = (uint32) (512 * 1024 * 1024 / rowblockbytes); + rowblocksperstrip = (uint32_t) (512 * 1024 * 1024 / rowblockbytes); if( rowblocksperstrip == 0 ) rowblocksperstrip = 1; rowsperstrip = rowblocksperstrip * rowblock; @@ -6057,9 +6057,9 @@ static void TryChopUpUncompressedBigTiff( TIFF* tif ) if( tif->tif_mode == O_RDONLY && nstrips > 1000000 ) { - uint64 last_offset = TIFFGetStrileOffset(tif, td->td_nstrips-1); - uint64 filesize = TIFFGetFileSize(tif); - uint64 last_bytecount = TIFFGetStrileByteCount(tif, td->td_nstrips-1); + uint64_t last_offset = TIFFGetStrileOffset(tif, td->td_nstrips - 1); + uint64_t filesize = TIFFGetFileSize(tif); + uint64_t last_bytecount = TIFFGetStrileByteCount(tif, td->td_nstrips - 1); if( last_offset > filesize || last_bytecount > filesize - last_offset ) { @@ -6072,7 +6072,7 @@ static void TryChopUpUncompressedBigTiff( TIFF* tif ) TIFF_NOSANITIZE_UNSIGNED_INT_OVERFLOW -static uint64 _TIFFUnsanitizedAddUInt64AndInt(uint64 a, int b) +static uint64_t _TIFFUnsanitizedAddUInt64AndInt(uint64_t a, int b) { return a + b; } @@ -6082,8 +6082,8 @@ static uint64 _TIFFUnsanitizedAddUInt64AndInt(uint64 a, int b) * 4096 byte page size. */ static -int _TIFFPartialReadStripArray( TIFF* tif, TIFFDirEntry* dirent, - int strile, uint64* panVals ) +int _TIFFPartialReadStripArray(TIFF* tif, TIFFDirEntry* dirent, + int strile, uint64_t* panVals ) { static const char module[] = "_TIFFPartialReadStripArray"; #define IO_CACHE_PAGE_SIZE 4096 @@ -6091,37 +6091,37 @@ int _TIFFPartialReadStripArray( TIFF* tif, TIFFDirEntry* dirent, size_t sizeofval; const int bSwab = (tif->tif_flags & TIFF_SWAB) != 0; int sizeofvalint; - uint64 nBaseOffset; - uint64 nOffset; - uint64 nOffsetStartPage; - uint64 nOffsetEndPage; + uint64_t nBaseOffset; + uint64_t nOffset; + uint64_t nOffsetStartPage; + uint64_t nOffsetEndPage; tmsize_t nToRead; tmsize_t nRead; - uint64 nLastStripOffset; + uint64_t nLastStripOffset; int iStartBefore; int i; - const uint32 arraySize = tif->tif_dir.td_stripoffsetbyteallocsize; + const uint32_t arraySize = tif->tif_dir.td_stripoffsetbyteallocsize; unsigned char buffer[2 * IO_CACHE_PAGE_SIZE]; assert( dirent->tdir_count > 4 ); if( dirent->tdir_type == TIFF_SHORT ) { - sizeofval = sizeof(uint16); + sizeofval = sizeof(uint16_t); } else if( dirent->tdir_type == TIFF_LONG ) { - sizeofval = sizeof(uint32); + sizeofval = sizeof(uint32_t); } else if( dirent->tdir_type == TIFF_LONG8 ) { - sizeofval = sizeof(uint64); + sizeofval = sizeof(uint64_t); } else if( dirent->tdir_type == TIFF_SLONG8 ) { /* Non conformant but used by some images as in */ /* https://github.com/OSGeo/gdal/issues/2165 */ - sizeofval = sizeof(int64); + sizeofval = sizeof(int64_t); } else { @@ -6134,20 +6134,20 @@ int _TIFFPartialReadStripArray( TIFF* tif, TIFFDirEntry* dirent, if( tif->tif_flags&TIFF_BIGTIFF ) { - uint64 offset = dirent->tdir_offset.toff_long8; + uint64_t offset = dirent->tdir_offset.toff_long8; if( bSwab ) TIFFSwabLong8(&offset); nBaseOffset = offset; } else { - uint32 offset = dirent->tdir_offset.toff_long; + uint32_t offset = dirent->tdir_offset.toff_long; if( bSwab ) TIFFSwabLong(&offset); nBaseOffset = offset; } /* To avoid later unsigned integer overflows */ - if( nBaseOffset > (uint64)TIFF_INT64_MAX ) + if( nBaseOffset > (uint64_t)INT64_MAX ) { TIFFErrorExt(tif->tif_clientdata, module, "Cannot read offset/size for strile %d", strile); @@ -6191,13 +6191,13 @@ int _TIFFPartialReadStripArray( TIFF* tif, TIFFDirEntry* dirent, if( strile + iStartBefore < 0 ) iStartBefore = -strile; for( i = iStartBefore; - (uint32)(strile + i) < arraySize && + (uint32_t)(strile + i) < arraySize && _TIFFUnsanitizedAddUInt64AndInt(nOffset, (i + 1) * sizeofvalint) <= nOffsetEndPage; ++i ) { if( dirent->tdir_type == TIFF_SHORT ) { - uint16 val; + uint16_t val; memcpy(&val, buffer + (nOffset - nOffsetStartPage) + i * sizeofvalint, sizeof(val)); @@ -6207,7 +6207,7 @@ int _TIFFPartialReadStripArray( TIFF* tif, TIFFDirEntry* dirent, } else if( dirent->tdir_type == TIFF_LONG ) { - uint32 val; + uint32_t val; memcpy(&val, buffer + (nOffset - nOffsetStartPage) + i * sizeofvalint, sizeof(val)); @@ -6217,7 +6217,7 @@ int _TIFFPartialReadStripArray( TIFF* tif, TIFFDirEntry* dirent, } else if( dirent->tdir_type == TIFF_LONG8 ) { - uint64 val; + uint64_t val; memcpy(&val, buffer + (nOffset - nOffsetStartPage) + i * sizeofvalint, sizeof(val)); @@ -6228,22 +6228,22 @@ int _TIFFPartialReadStripArray( TIFF* tif, TIFFDirEntry* dirent, else /* if( dirent->tdir_type == TIFF_SLONG8 ) */ { /* Non conformant data type */ - int64 val; + int64_t val; memcpy(&val, buffer + (nOffset - nOffsetStartPage) + i * sizeofvalint, sizeof(val)); if( bSwab ) - TIFFSwabLong8((uint64*) &val); - panVals[strile + i] = (uint64) val; + TIFFSwabLong8((uint64_t*) &val); + panVals[strile + i] = (uint64_t) val; } } return 1; } static int _TIFFFetchStrileValue(TIFF* tif, - uint32 strile, + uint32_t strile, TIFFDirEntry* dirent, - uint64** parray) + uint64_t** parray) { static const char module[] = "_TIFFFetchStrileValue"; TIFFDirectory *td = &tif->tif_dir; @@ -6253,20 +6253,20 @@ static int _TIFFFetchStrileValue(TIFF* tif, } if( strile >= td->td_stripoffsetbyteallocsize ) { - uint32 nStripArrayAllocBefore = td->td_stripoffsetbyteallocsize; - uint32 nStripArrayAllocNew; - uint64 nArraySize64; + uint32_t nStripArrayAllocBefore = td->td_stripoffsetbyteallocsize; + uint32_t nStripArrayAllocNew; + uint64_t nArraySize64; size_t nArraySize; - uint64* offsetArray; - uint64* bytecountArray; + uint64_t* offsetArray; + uint64_t* bytecountArray; if( strile > 1000000 ) { - uint64 filesize = TIFFGetFileSize(tif); + uint64_t filesize = TIFFGetFileSize(tif); /* Avoid excessive memory allocation attempt */ /* For such a big blockid we need at least a TIFF_LONG per strile */ /* for the offset array. */ - if( strile > filesize / sizeof(uint32) ) + if( strile > filesize / sizeof(uint32_t) ) { TIFFErrorExt(tif->tif_clientdata, module, "File too short"); return 0; @@ -6288,7 +6288,7 @@ static int _TIFFFetchStrileValue(TIFF* tif, nStripArrayAllocNew = TIFF_MIN(nStripArrayAllocNew, td->td_nstrips); } assert( strile < nStripArrayAllocNew ); - nArraySize64 = (uint64)sizeof(uint64) * nStripArrayAllocNew; + nArraySize64 = (uint64_t)sizeof(uint64_t) * nStripArrayAllocNew; nArraySize = (size_t)(nArraySize64); #if SIZEOF_SIZE_T == 4 if( nArraySize != nArraySize64 ) @@ -6298,9 +6298,9 @@ static int _TIFFFetchStrileValue(TIFF* tif, return 0; } #endif - offsetArray = (uint64*)( + offsetArray = (uint64_t*)( _TIFFrealloc( td->td_stripoffset_p, nArraySize ) ); - bytecountArray = (uint64*)( + bytecountArray = (uint64_t*)( _TIFFrealloc( td->td_stripbytecount_p, nArraySize ) ); if( offsetArray ) td->td_stripoffset_p = offsetArray; @@ -6312,10 +6312,10 @@ static int _TIFFFetchStrileValue(TIFF* tif, /* Initialize new entries to ~0 / -1 */ memset(td->td_stripoffset_p + nStripArrayAllocBefore, 0xFF, - (td->td_stripoffsetbyteallocsize - nStripArrayAllocBefore) * sizeof(uint64) ); + (td->td_stripoffsetbyteallocsize - nStripArrayAllocBefore) * sizeof(uint64_t) ); memset(td->td_stripbytecount_p + nStripArrayAllocBefore, 0xFF, - (td->td_stripoffsetbyteallocsize - nStripArrayAllocBefore) * sizeof(uint64) ); + (td->td_stripoffsetbyteallocsize - nStripArrayAllocBefore) * sizeof(uint64_t) ); } else { @@ -6343,10 +6343,10 @@ static int _TIFFFetchStrileValue(TIFF* tif, return 1; } -static uint64 _TIFFGetStrileOffsetOrByteCountValue(TIFF *tif, uint32 strile, - TIFFDirEntry* dirent, - uint64** parray, - int *pbErr) +static uint64_t _TIFFGetStrileOffsetOrByteCountValue(TIFF *tif, uint32_t strile, + TIFFDirEntry* dirent, + uint64_t** parray, + int *pbErr) { TIFFDirectory *td = &tif->tif_dir; if( pbErr ) @@ -6387,13 +6387,13 @@ static uint64 _TIFFGetStrileOffsetOrByteCountValue(TIFF *tif, uint32 strile, } /* Return the value of the TileOffsets/StripOffsets array for the specified tile/strile */ -uint64 TIFFGetStrileOffset(TIFF *tif, uint32 strile) +uint64_t TIFFGetStrileOffset(TIFF *tif, uint32_t strile) { return TIFFGetStrileOffsetWithErr(tif, strile, NULL); } /* Return the value of the TileOffsets/StripOffsets array for the specified tile/strile */ -uint64 TIFFGetStrileOffsetWithErr(TIFF *tif, uint32 strile, int *pbErr) +uint64_t TIFFGetStrileOffsetWithErr(TIFF *tif, uint32_t strile, int *pbErr) { TIFFDirectory *td = &tif->tif_dir; return _TIFFGetStrileOffsetOrByteCountValue(tif, strile, @@ -6402,13 +6402,13 @@ uint64 TIFFGetStrileOffsetWithErr(TIFF *tif, uint32 strile, int *pbErr) } /* Return the value of the TileByteCounts/StripByteCounts array for the specified tile/strile */ -uint64 TIFFGetStrileByteCount(TIFF *tif, uint32 strile) +uint64_t TIFFGetStrileByteCount(TIFF *tif, uint32_t strile) { return TIFFGetStrileByteCountWithErr(tif, strile, NULL); } /* Return the value of the TileByteCounts/StripByteCounts array for the specified tile/strile */ -uint64 TIFFGetStrileByteCountWithErr(TIFF *tif, uint32 strile, int *pbErr) +uint64_t TIFFGetStrileByteCountWithErr(TIFF *tif, uint32_t strile, int *pbErr) { TIFFDirectory *td = &tif->tif_dir; return _TIFFGetStrileOffsetOrByteCountValue(tif, strile, @@ -6468,7 +6468,7 @@ static int _TIFFFillStrilesInternal( TIFF *tif, int loadStripByteCount ) #ifdef STRIPBYTECOUNTSORTED_UNUSED if (tif->tif_dir.td_nstrips > 1 && return_value == 1 ) { - uint32 strip; + uint32_t strip; tif->tif_dir.td_stripbytecountsorted = 1; for (strip = 1; strip < tif->tif_dir.td_nstrips; strip++) { diff --git a/tiff/libtiff/tif_dirwrite.c b/tiff/libtiff/tif_dirwrite.c index f481250e..12d67be6 100644 --- a/tiff/libtiff/tif_dirwrite.c +++ b/tiff/libtiff/tif_dirwrite.c @@ -35,152 +35,152 @@ #define TIFFCvtNativeToIEEEFloat(tif, n, fp) #define TIFFCvtNativeToIEEEDouble(tif, n, dp) #else -extern void TIFFCvtNativeToIEEEFloat(TIFF* tif, uint32 n, float* fp); -extern void TIFFCvtNativeToIEEEDouble(TIFF* tif, uint32 n, double* dp); +extern void TIFFCvtNativeToIEEEFloat(TIFF* tif, uint32_t n, float* fp); +extern void TIFFCvtNativeToIEEEDouble(TIFF* tif, uint32_t n, double* dp); #endif -static int TIFFWriteDirectorySec(TIFF* tif, int isimage, int imagedone, uint64* pdiroff); +static int TIFFWriteDirectorySec(TIFF* tif, int isimage, int imagedone, uint64_t* pdiroff); -static int TIFFWriteDirectoryTagSampleformatArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, double* value); +static int TIFFWriteDirectoryTagSampleformatArray(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, double* value); #if 0 -static int TIFFWriteDirectoryTagSampleformatPerSample(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, double value); +static int TIFFWriteDirectoryTagSampleformatPerSample(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, double value); #endif -static int TIFFWriteDirectoryTagAscii(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, char* value); -static int TIFFWriteDirectoryTagUndefinedArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, uint8* value); +static int TIFFWriteDirectoryTagAscii(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, char* value); +static int TIFFWriteDirectoryTagUndefinedArray(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, uint8_t* value); #ifdef notdef -static int TIFFWriteDirectoryTagByte(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint8 value); +static int TIFFWriteDirectoryTagByte(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint8_t value); #endif -static int TIFFWriteDirectoryTagByteArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, uint8* value); +static int TIFFWriteDirectoryTagByteArray(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, uint8_t* value); #if 0 -static int TIFFWriteDirectoryTagBytePerSample(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint8 value); +static int TIFFWriteDirectoryTagBytePerSample(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint8_t value); #endif #ifdef notdef -static int TIFFWriteDirectoryTagSbyte(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, int8 value); +static int TIFFWriteDirectoryTagSbyte(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, int8_t value); #endif -static int TIFFWriteDirectoryTagSbyteArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, int8* value); +static int TIFFWriteDirectoryTagSbyteArray(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, int8_t* value); #if 0 -static int TIFFWriteDirectoryTagSbytePerSample(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, int8 value); +static int TIFFWriteDirectoryTagSbytePerSample(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, int8_t value); #endif -static int TIFFWriteDirectoryTagShort(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint16 value); -static int TIFFWriteDirectoryTagShortArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, uint16* value); -static int TIFFWriteDirectoryTagShortPerSample(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint16 value); +static int TIFFWriteDirectoryTagShort(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint16_t value); +static int TIFFWriteDirectoryTagShortArray(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, uint16_t* value); +static int TIFFWriteDirectoryTagShortPerSample(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint16_t value); #ifdef notdef -static int TIFFWriteDirectoryTagSshort(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, int16 value); +static int TIFFWriteDirectoryTagSshort(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, int16_t value); #endif -static int TIFFWriteDirectoryTagSshortArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, int16* value); +static int TIFFWriteDirectoryTagSshortArray(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, int16_t* value); #if 0 -static int TIFFWriteDirectoryTagSshortPerSample(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, int16 value); +static int TIFFWriteDirectoryTagSshortPerSample(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, int16_t value); #endif -static int TIFFWriteDirectoryTagLong(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 value); -static int TIFFWriteDirectoryTagLongArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, uint32* value); +static int TIFFWriteDirectoryTagLong(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t value); +static int TIFFWriteDirectoryTagLongArray(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, uint32_t* value); #if 0 -static int TIFFWriteDirectoryTagLongPerSample(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 value); +static int TIFFWriteDirectoryTagLongPerSample(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t value); #endif #ifdef notdef -static int TIFFWriteDirectoryTagSlong(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, int32 value); +static int TIFFWriteDirectoryTagSlong(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, int32_t value); #endif -static int TIFFWriteDirectoryTagSlongArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, int32* value); +static int TIFFWriteDirectoryTagSlongArray(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, int32_t* value); #if 0 -static int TIFFWriteDirectoryTagSlongPerSample(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, int32 value); +static int TIFFWriteDirectoryTagSlongPerSample(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, int32_t value); #endif #ifdef notdef -static int TIFFWriteDirectoryTagLong8(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint64 value); +static int TIFFWriteDirectoryTagLong8(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint64_t value); #endif -static int TIFFWriteDirectoryTagLong8Array(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, uint64* value); +static int TIFFWriteDirectoryTagLong8Array(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, uint64_t* value); #ifdef notdef -static int TIFFWriteDirectoryTagSlong8(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, int64 value); +static int TIFFWriteDirectoryTagSlong8(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, int64_t value); #endif -static int TIFFWriteDirectoryTagSlong8Array(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, int64* value); -static int TIFFWriteDirectoryTagRational(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, double value); -static int TIFFWriteDirectoryTagRationalArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, float* value); -static int TIFFWriteDirectoryTagSrationalArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, float* value); +static int TIFFWriteDirectoryTagSlong8Array(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, int64_t* value); +static int TIFFWriteDirectoryTagRational(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, double value); +static int TIFFWriteDirectoryTagRationalArray(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, float* value); +static int TIFFWriteDirectoryTagSrationalArray(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, float* value); #ifdef notdef -static int TIFFWriteDirectoryTagFloat(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, float value); +static int TIFFWriteDirectoryTagFloat(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, float value); #endif -static int TIFFWriteDirectoryTagFloatArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, float* value); +static int TIFFWriteDirectoryTagFloatArray(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, float* value); #if 0 -static int TIFFWriteDirectoryTagFloatPerSample(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, float value); +static int TIFFWriteDirectoryTagFloatPerSample(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, float value); #endif #ifdef notdef -static int TIFFWriteDirectoryTagDouble(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, double value); +static int TIFFWriteDirectoryTagDouble(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, double value); #endif -static int TIFFWriteDirectoryTagDoubleArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, double* value); +static int TIFFWriteDirectoryTagDoubleArray(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, double* value); #if 0 -static int TIFFWriteDirectoryTagDoublePerSample(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, double value); +static int TIFFWriteDirectoryTagDoublePerSample(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, double value); #endif -static int TIFFWriteDirectoryTagIfdArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, uint32* value); +static int TIFFWriteDirectoryTagIfdArray(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, uint32_t* value); #ifdef notdef -static int TIFFWriteDirectoryTagIfd8Array(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, uint64* value); +static int TIFFWriteDirectoryTagIfd8Array(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, uint64_t* value); #endif -static int TIFFWriteDirectoryTagShortLong(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 value); -static int TIFFWriteDirectoryTagLongLong8Array(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, uint64* value); -static int TIFFWriteDirectoryTagIfdIfd8Array(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, uint64* value); +static int TIFFWriteDirectoryTagShortLong(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t value); +static int TIFFWriteDirectoryTagLongLong8Array(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, uint64_t* value); +static int TIFFWriteDirectoryTagIfdIfd8Array(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, uint64_t* value); #ifdef notdef -static int TIFFWriteDirectoryTagShortLongLong8Array(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, uint64* value); +static int TIFFWriteDirectoryTagShortLongLong8Array(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, uint64_t* value); #endif -static int TIFFWriteDirectoryTagColormap(TIFF* tif, uint32* ndir, TIFFDirEntry* dir); -static int TIFFWriteDirectoryTagTransferfunction(TIFF* tif, uint32* ndir, TIFFDirEntry* dir); -static int TIFFWriteDirectoryTagSubifd(TIFF* tif, uint32* ndir, TIFFDirEntry* dir); +static int TIFFWriteDirectoryTagColormap(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir); +static int TIFFWriteDirectoryTagTransferfunction(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir); +static int TIFFWriteDirectoryTagSubifd(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir); -static int TIFFWriteDirectoryTagCheckedAscii(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, char* value); -static int TIFFWriteDirectoryTagCheckedUndefinedArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, uint8* value); +static int TIFFWriteDirectoryTagCheckedAscii(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, char* value); +static int TIFFWriteDirectoryTagCheckedUndefinedArray(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, uint8_t* value); #ifdef notdef -static int TIFFWriteDirectoryTagCheckedByte(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint8 value); +static int TIFFWriteDirectoryTagCheckedByte(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint8_t value); #endif -static int TIFFWriteDirectoryTagCheckedByteArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, uint8* value); +static int TIFFWriteDirectoryTagCheckedByteArray(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, uint8_t* value); #ifdef notdef -static int TIFFWriteDirectoryTagCheckedSbyte(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, int8 value); +static int TIFFWriteDirectoryTagCheckedSbyte(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, int8_t value); #endif -static int TIFFWriteDirectoryTagCheckedSbyteArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, int8* value); -static int TIFFWriteDirectoryTagCheckedShort(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint16 value); -static int TIFFWriteDirectoryTagCheckedShortArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, uint16* value); +static int TIFFWriteDirectoryTagCheckedSbyteArray(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, int8_t* value); +static int TIFFWriteDirectoryTagCheckedShort(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint16_t value); +static int TIFFWriteDirectoryTagCheckedShortArray(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, uint16_t* value); #ifdef notdef -static int TIFFWriteDirectoryTagCheckedSshort(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, int16 value); +static int TIFFWriteDirectoryTagCheckedSshort(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, int16_t value); #endif -static int TIFFWriteDirectoryTagCheckedSshortArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, int16* value); -static int TIFFWriteDirectoryTagCheckedLong(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 value); -static int TIFFWriteDirectoryTagCheckedLongArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, uint32* value); +static int TIFFWriteDirectoryTagCheckedSshortArray(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, int16_t* value); +static int TIFFWriteDirectoryTagCheckedLong(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t value); +static int TIFFWriteDirectoryTagCheckedLongArray(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, uint32_t* value); #ifdef notdef -static int TIFFWriteDirectoryTagCheckedSlong(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, int32 value); +static int TIFFWriteDirectoryTagCheckedSlong(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, int32_t value); #endif -static int TIFFWriteDirectoryTagCheckedSlongArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, int32* value); +static int TIFFWriteDirectoryTagCheckedSlongArray(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, int32_t* value); #ifdef notdef -static int TIFFWriteDirectoryTagCheckedLong8(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint64 value); +static int TIFFWriteDirectoryTagCheckedLong8(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint64_t value); #endif -static int TIFFWriteDirectoryTagCheckedLong8Array(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, uint64* value); +static int TIFFWriteDirectoryTagCheckedLong8Array(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, uint64_t* value); #ifdef notdef -static int TIFFWriteDirectoryTagCheckedSlong8(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, int64 value); +static int TIFFWriteDirectoryTagCheckedSlong8(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, int64_t value); #endif -static int TIFFWriteDirectoryTagCheckedSlong8Array(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, int64* value); -static int TIFFWriteDirectoryTagCheckedRational(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, double value); -static int TIFFWriteDirectoryTagCheckedRationalArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, float* value); -static int TIFFWriteDirectoryTagCheckedSrationalArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, float* value); +static int TIFFWriteDirectoryTagCheckedSlong8Array(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, int64_t* value); +static int TIFFWriteDirectoryTagCheckedRational(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, double value); +static int TIFFWriteDirectoryTagCheckedRationalArray(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, float* value); +static int TIFFWriteDirectoryTagCheckedSrationalArray(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, float* value); /*--: Rational2Double: New functions to support true double-precision for custom rational tag types. */ -static int TIFFWriteDirectoryTagRationalDoubleArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, double* value); -static int TIFFWriteDirectoryTagSrationalDoubleArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, double* value); -static int TIFFWriteDirectoryTagCheckedRationalDoubleArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, double* value); -static int TIFFWriteDirectoryTagCheckedSrationalDoubleArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, double* value); -static void DoubleToRational(double value, uint32 *num, uint32 *denom); -static void DoubleToSrational(double value, int32 *num, int32 *denom); +static int TIFFWriteDirectoryTagRationalDoubleArray(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, double* value); +static int TIFFWriteDirectoryTagSrationalDoubleArray(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, double* value); +static int TIFFWriteDirectoryTagCheckedRationalDoubleArray(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, double* value); +static int TIFFWriteDirectoryTagCheckedSrationalDoubleArray(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, double* value); +static void DoubleToRational(double value, uint32_t *num, uint32_t *denom); +static void DoubleToSrational(double value, int32_t *num, int32_t *denom); #if 0 static void DoubleToRational_direct(double value, unsigned long *num, unsigned long *denom); static void DoubleToSrational_direct(double value, long *num, long *denom); #endif #ifdef notdef -static int TIFFWriteDirectoryTagCheckedFloat(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, float value); +static int TIFFWriteDirectoryTagCheckedFloat(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, float value); #endif -static int TIFFWriteDirectoryTagCheckedFloatArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, float* value); +static int TIFFWriteDirectoryTagCheckedFloatArray(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, float* value); #ifdef notdef -static int TIFFWriteDirectoryTagCheckedDouble(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, double value); +static int TIFFWriteDirectoryTagCheckedDouble(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, double value); #endif -static int TIFFWriteDirectoryTagCheckedDoubleArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, double* value); -static int TIFFWriteDirectoryTagCheckedIfdArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, uint32* value); -static int TIFFWriteDirectoryTagCheckedIfd8Array(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, uint64* value); +static int TIFFWriteDirectoryTagCheckedDoubleArray(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, double* value); +static int TIFFWriteDirectoryTagCheckedIfdArray(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, uint32_t* value); +static int TIFFWriteDirectoryTagCheckedIfd8Array(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, uint64_t* value); -static int TIFFWriteDirectoryTagData(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint16 datatype, uint32 count, uint32 datalength, void* data); +static int TIFFWriteDirectoryTagData(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint16_t datatype, uint32_t count, uint32_t datalength, void* data); static int TIFFLinkDirectory(TIFF*); @@ -260,7 +260,7 @@ TIFFCheckpointDirectory(TIFF* tif) } int -TIFFWriteCustomDirectory(TIFF* tif, uint64* pdiroff) +TIFFWriteCustomDirectory(TIFF* tif, uint64_t* pdiroff) { return TIFFWriteDirectorySec(tif,FALSE,FALSE,pdiroff); } @@ -302,11 +302,11 @@ TIFFRewriteDirectory( TIFF *tif ) } else { - uint32 nextdir; + uint32_t nextdir; nextdir = tif->tif_header.classic.tiff_diroff; while(1) { - uint16 dircount; - uint32 nextnextdir; + uint16_t dircount; + uint32_t nextnextdir; if (!SeekOK(tif, nextdir) || !ReadOK(tif, &dircount, 2)) { @@ -327,7 +327,7 @@ TIFFRewriteDirectory( TIFF *tif ) TIFFSwabLong(&nextnextdir); if (nextnextdir==tif->tif_diroff) { - uint32 m; + uint32_t m; m=0; (void) TIFFSeekFile(tif, nextdir+2+dircount*12, SEEK_SET); @@ -360,12 +360,12 @@ TIFFRewriteDirectory( TIFF *tif ) } else { - uint64 nextdir; + uint64_t nextdir; nextdir = tif->tif_header.big.tiff_diroff; while(1) { - uint64 dircount64; - uint16 dircount; - uint64 nextnextdir; + uint64_t dircount64; + uint16_t dircount; + uint64_t nextnextdir; if (!SeekOK(tif, nextdir) || !ReadOK(tif, &dircount64, 8)) { @@ -381,7 +381,7 @@ TIFFRewriteDirectory( TIFF *tif ) "Sanity check on tag count failed, likely corrupt TIFF"); return (0); } - dircount=(uint16)dircount64; + dircount=(uint16_t)dircount64; (void) TIFFSeekFile(tif, nextdir+8+dircount*20, SEEK_SET); if (!ReadOK(tif, &nextnextdir, 8)) { @@ -393,7 +393,7 @@ TIFFRewriteDirectory( TIFF *tif ) TIFFSwabLong8(&nextnextdir); if (nextnextdir==tif->tif_diroff) { - uint64 m; + uint64_t m; m=0; (void) TIFFSeekFile(tif, nextdir+8+dircount*20, SEEK_SET); @@ -418,14 +418,14 @@ TIFFRewriteDirectory( TIFF *tif ) } static int -TIFFWriteDirectorySec(TIFF* tif, int isimage, int imagedone, uint64* pdiroff) +TIFFWriteDirectorySec(TIFF* tif, int isimage, int imagedone, uint64_t* pdiroff) { static const char module[] = "TIFFWriteDirectorySec"; - uint32 ndir; + uint32_t ndir; TIFFDirEntry* dir; - uint32 dirsize; + uint32_t dirsize; void* dirmem; - uint32 m; + uint32_t m; if (tif->tif_mode == O_RDONLY) return (1); @@ -630,8 +630,8 @@ TIFFWriteDirectorySec(TIFF* tif, int isimage, int imagedone, uint64* pdiroff) { if (tif->tif_dir.td_extrasamples) { - uint16 na; - uint16* nb; + uint16_t na; + uint16_t* nb; TIFFGetFieldDefaulted(tif,TIFFTAG_EXTRASAMPLES,&na,&nb); if (!TIFFWriteDirectoryTagShortArray(tif,&ndir,dir,TIFFTAG_EXTRASAMPLES,na,nb)) goto bad; @@ -698,7 +698,7 @@ TIFFWriteDirectorySec(TIFF* tif, int isimage, int imagedone, uint64* pdiroff) goto bad; } { - uint32 n; + uint32_t n; for (n=0; n<tif->tif_nfields; n++) { const TIFFField* o; o = tif->tif_fields[n]; @@ -708,54 +708,54 @@ TIFFWriteDirectorySec(TIFF* tif, int isimage, int imagedone, uint64* pdiroff) { case TIFF_SETGET_ASCII: { - uint32 pa; + uint32_t pa; char* pb; assert(o->field_type==TIFF_ASCII); assert(o->field_readcount==TIFF_VARIABLE); assert(o->field_passcount==0); TIFFGetField(tif,o->field_tag,&pb); - pa=(uint32)(strlen(pb)); - if (!TIFFWriteDirectoryTagAscii(tif,&ndir,dir,(uint16)o->field_tag,pa,pb)) + pa=(uint32_t)(strlen(pb)); + if (!TIFFWriteDirectoryTagAscii(tif, &ndir, dir, (uint16_t)o->field_tag, pa, pb)) goto bad; } break; case TIFF_SETGET_UINT16: { - uint16 p; + uint16_t p; assert(o->field_type==TIFF_SHORT); assert(o->field_readcount==1); assert(o->field_passcount==0); TIFFGetField(tif,o->field_tag,&p); - if (!TIFFWriteDirectoryTagShort(tif,&ndir,dir,(uint16)o->field_tag,p)) + if (!TIFFWriteDirectoryTagShort(tif, &ndir, dir, (uint16_t)o->field_tag, p)) goto bad; } break; case TIFF_SETGET_UINT32: { - uint32 p; + uint32_t p; assert(o->field_type==TIFF_LONG); assert(o->field_readcount==1); assert(o->field_passcount==0); TIFFGetField(tif,o->field_tag,&p); - if (!TIFFWriteDirectoryTagLong(tif,&ndir,dir,(uint16)o->field_tag,p)) + if (!TIFFWriteDirectoryTagLong(tif, &ndir, dir, (uint16_t)o->field_tag, p)) goto bad; } break; case TIFF_SETGET_C32_UINT8: { - uint32 pa; + uint32_t pa; void* pb; assert(o->field_type==TIFF_UNDEFINED); assert(o->field_readcount==TIFF_VARIABLE2); assert(o->field_passcount==1); TIFFGetField(tif,o->field_tag,&pa,&pb); - if (!TIFFWriteDirectoryTagUndefinedArray(tif,&ndir,dir,(uint16)o->field_tag,pa,pb)) + if (!TIFFWriteDirectoryTagUndefinedArray(tif, &ndir, dir, (uint16_t)o->field_tag, pa, pb)) goto bad; } break; default: TIFFErrorExt(tif->tif_clientdata,module, - "Cannot write tag %d (%s)", + "Cannot write tag %"PRIu32" (%s)", TIFFFieldTag(o), o->field_name ? o->field_name : "unknown"); goto bad; @@ -764,10 +764,10 @@ TIFFWriteDirectorySec(TIFF* tif, int isimage, int imagedone, uint64* pdiroff) } } } - for (m=0; m<(uint32)(tif->tif_dir.td_customValueCount); m++) + for (m=0; m<(uint32_t)(tif->tif_dir.td_customValueCount); m++) { - uint16 tag = (uint16)tif->tif_dir.td_customValues[m].info->field_tag; - uint32 count = tif->tif_dir.td_customValues[m].count; + uint16_t tag = (uint16_t)tif->tif_dir.td_customValues[m].info->field_tag; + uint32_t count = tif->tif_dir.td_customValues[m].count; switch (tif->tif_dir.td_customValues[m].info->field_type) { case TIFF_ASCII: @@ -892,8 +892,8 @@ TIFFWriteDirectorySec(TIFF* tif, int isimage, int imagedone, uint64* pdiroff) dirsize=8+ndir*20+8; tif->tif_dataoff=tif->tif_diroff+dirsize; if (!(tif->tif_flags&TIFF_BIGTIFF)) - tif->tif_dataoff=(uint32)tif->tif_dataoff; - if ((tif->tif_dataoff<tif->tif_diroff)||(tif->tif_dataoff<(uint64)dirsize)) + tif->tif_dataoff=(uint32_t)tif->tif_dataoff; + if ((tif->tif_dataoff<tif->tif_diroff)||(tif->tif_dataoff<(uint64_t)dirsize)) { TIFFErrorExt(tif->tif_clientdata,module,"Maximum TIFF file size exceeded"); goto bad; @@ -907,7 +907,7 @@ TIFFWriteDirectorySec(TIFF* tif, int isimage, int imagedone, uint64* pdiroff) { if (TIFFFieldSet(tif,FIELD_SUBIFD)&&(tif->tif_subifdoff==0)) { - uint32 na; + uint32_t na; TIFFDirEntry* nb; for (na=0, nb=dir; ; na++, nb++) { @@ -934,29 +934,29 @@ TIFFWriteDirectorySec(TIFF* tif, int isimage, int imagedone, uint64* pdiroff) } if (!(tif->tif_flags&TIFF_BIGTIFF)) { - uint8* n; - uint32 nTmp; + uint8_t* n; + uint32_t nTmp; TIFFDirEntry* o; n=dirmem; - *(uint16*)n=(uint16)ndir; + *(uint16_t*)n=(uint16_t)ndir; if (tif->tif_flags&TIFF_SWAB) - TIFFSwabShort((uint16*)n); + TIFFSwabShort((uint16_t*)n); n+=2; o=dir; for (m=0; m<ndir; m++) { - *(uint16*)n=o->tdir_tag; + *(uint16_t*)n=o->tdir_tag; if (tif->tif_flags&TIFF_SWAB) - TIFFSwabShort((uint16*)n); + TIFFSwabShort((uint16_t*)n); n+=2; - *(uint16*)n=o->tdir_type; + *(uint16_t*)n=o->tdir_type; if (tif->tif_flags&TIFF_SWAB) - TIFFSwabShort((uint16*)n); + TIFFSwabShort((uint16_t*)n); n+=2; - nTmp = (uint32)o->tdir_count; + nTmp = (uint32_t)o->tdir_count; _TIFFmemcpy(n,&nTmp,4); if (tif->tif_flags&TIFF_SWAB) - TIFFSwabLong((uint32*)n); + TIFFSwabLong((uint32_t*)n); n+=4; /* This is correct. The data has been */ /* swabbed previously in TIFFWriteDirectoryTagData */ @@ -964,34 +964,34 @@ TIFFWriteDirectorySec(TIFF* tif, int isimage, int imagedone, uint64* pdiroff) n+=4; o++; } - nTmp = (uint32)tif->tif_nextdiroff; + nTmp = (uint32_t)tif->tif_nextdiroff; if (tif->tif_flags&TIFF_SWAB) TIFFSwabLong(&nTmp); _TIFFmemcpy(n,&nTmp,4); } else { - uint8* n; + uint8_t* n; TIFFDirEntry* o; n=dirmem; - *(uint64*)n=ndir; + *(uint64_t*)n=ndir; if (tif->tif_flags&TIFF_SWAB) - TIFFSwabLong8((uint64*)n); + TIFFSwabLong8((uint64_t*)n); n+=8; o=dir; for (m=0; m<ndir; m++) { - *(uint16*)n=o->tdir_tag; + *(uint16_t*)n=o->tdir_tag; if (tif->tif_flags&TIFF_SWAB) - TIFFSwabShort((uint16*)n); + TIFFSwabShort((uint16_t*)n); n+=2; - *(uint16*)n=o->tdir_type; + *(uint16_t*)n=o->tdir_type; if (tif->tif_flags&TIFF_SWAB) - TIFFSwabShort((uint16*)n); + TIFFSwabShort((uint16_t*)n); n+=2; _TIFFmemcpy(n,&o->tdir_count,8); if (tif->tif_flags&TIFF_SWAB) - TIFFSwabLong8((uint64*)n); + TIFFSwabLong8((uint64_t*)n); n+=8; _TIFFmemcpy(n,&o->tdir_offset,8); n+=8; @@ -999,7 +999,7 @@ TIFFWriteDirectorySec(TIFF* tif, int isimage, int imagedone, uint64* pdiroff) } _TIFFmemcpy(n,&tif->tif_nextdiroff,8); if (tif->tif_flags&TIFF_SWAB) - TIFFSwabLong8((uint64*)n); + TIFFSwabLong8((uint64_t*)n); } _TIFFfree(dir); dir=NULL; @@ -1035,66 +1035,66 @@ bad: return(0); } -static int8 TIFFClampDoubleToInt8( double val ) +static int8_t TIFFClampDoubleToInt8(double val ) { if( val > 127 ) return 127; if( val < -128 || val != val ) return -128; - return (int8)val; + return (int8_t)val; } -static int16 TIFFClampDoubleToInt16( double val ) +static int16_t TIFFClampDoubleToInt16(double val ) { if( val > 32767 ) return 32767; if( val < -32768 || val != val ) return -32768; - return (int16)val; + return (int16_t)val; } -static int32 TIFFClampDoubleToInt32( double val ) +static int32_t TIFFClampDoubleToInt32(double val ) { if( val > 0x7FFFFFFF ) return 0x7FFFFFFF; if( val < -0x7FFFFFFF-1 || val != val ) return -0x7FFFFFFF-1; - return (int32)val; + return (int32_t)val; } -static uint8 TIFFClampDoubleToUInt8( double val ) +static uint8_t TIFFClampDoubleToUInt8(double val ) { if( val < 0 ) return 0; if( val > 255 || val != val ) return 255; - return (uint8)val; + return (uint8_t)val; } -static uint16 TIFFClampDoubleToUInt16( double val ) +static uint16_t TIFFClampDoubleToUInt16(double val ) { if( val < 0 ) return 0; if( val > 65535 || val != val ) return 65535; - return (uint16)val; + return (uint16_t)val; } -static uint32 TIFFClampDoubleToUInt32( double val ) +static uint32_t TIFFClampDoubleToUInt32(double val ) { if( val < 0 ) return 0; if( val > 0xFFFFFFFFU || val != val ) return 0xFFFFFFFFU; - return (uint32)val; + return (uint32_t)val; } static int -TIFFWriteDirectoryTagSampleformatArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, double* value) +TIFFWriteDirectoryTagSampleformatArray(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, double* value) { static const char module[] = "TIFFWriteDirectoryTagSampleformatArray"; void* conv; - uint32 i; + uint32_t i; int ok; conv = _TIFFmalloc(count*sizeof(double)); if (conv == NULL) @@ -1121,40 +1121,40 @@ TIFFWriteDirectoryTagSampleformatArray(TIFF* tif, uint32* ndir, TIFFDirEntry* di if (tif->tif_dir.td_bitspersample<=8) { for (i = 0; i < count; ++i) - ((int8*)conv)[i] = TIFFClampDoubleToInt8(value[i]); - ok = TIFFWriteDirectoryTagSbyteArray(tif,ndir,dir,tag,count,(int8*)conv); + ((int8_t*)conv)[i] = TIFFClampDoubleToInt8(value[i]); + ok = TIFFWriteDirectoryTagSbyteArray(tif,ndir,dir,tag,count,(int8_t*)conv); } else if (tif->tif_dir.td_bitspersample<=16) { for (i = 0; i < count; ++i) - ((int16*)conv)[i] = TIFFClampDoubleToInt16(value[i]); - ok = TIFFWriteDirectoryTagSshortArray(tif,ndir,dir,tag,count,(int16*)conv); + ((int16_t*)conv)[i] = TIFFClampDoubleToInt16(value[i]); + ok = TIFFWriteDirectoryTagSshortArray(tif,ndir,dir,tag,count,(int16_t*)conv); } else { for (i = 0; i < count; ++i) - ((int32*)conv)[i] = TIFFClampDoubleToInt32(value[i]); - ok = TIFFWriteDirectoryTagSlongArray(tif,ndir,dir,tag,count,(int32*)conv); + ((int32_t*)conv)[i] = TIFFClampDoubleToInt32(value[i]); + ok = TIFFWriteDirectoryTagSlongArray(tif,ndir,dir,tag,count,(int32_t*)conv); } break; case SAMPLEFORMAT_UINT: if (tif->tif_dir.td_bitspersample<=8) { for (i = 0; i < count; ++i) - ((uint8*)conv)[i] = TIFFClampDoubleToUInt8(value[i]); - ok = TIFFWriteDirectoryTagByteArray(tif,ndir,dir,tag,count,(uint8*)conv); + ((uint8_t*)conv)[i] = TIFFClampDoubleToUInt8(value[i]); + ok = TIFFWriteDirectoryTagByteArray(tif,ndir,dir,tag,count,(uint8_t*)conv); } else if (tif->tif_dir.td_bitspersample<=16) { for (i = 0; i < count; ++i) - ((uint16*)conv)[i] = TIFFClampDoubleToUInt16(value[i]); - ok = TIFFWriteDirectoryTagShortArray(tif,ndir,dir,tag,count,(uint16*)conv); + ((uint16_t*)conv)[i] = TIFFClampDoubleToUInt16(value[i]); + ok = TIFFWriteDirectoryTagShortArray(tif,ndir,dir,tag,count,(uint16_t*)conv); } else { for (i = 0; i < count; ++i) - ((uint32*)conv)[i] = TIFFClampDoubleToUInt32(value[i]); - ok = TIFFWriteDirectoryTagLongArray(tif,ndir,dir,tag,count,(uint32*)conv); + ((uint32_t*)conv)[i] = TIFFClampDoubleToUInt32(value[i]); + ok = TIFFWriteDirectoryTagLongArray(tif,ndir,dir,tag,count,(uint32_t*)conv); } break; default: @@ -1167,7 +1167,7 @@ TIFFWriteDirectoryTagSampleformatArray(TIFF* tif, uint32* ndir, TIFFDirEntry* di #if 0 static int -TIFFWriteDirectoryTagSampleformatPerSample(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, double value) +TIFFWriteDirectoryTagSampleformatPerSample(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, double value) { switch (tif->tif_dir.td_sampleformat) { @@ -1178,18 +1178,18 @@ TIFFWriteDirectoryTagSampleformatPerSample(TIFF* tif, uint32* ndir, TIFFDirEntry return(TIFFWriteDirectoryTagDoublePerSample(tif,ndir,dir,tag,value)); case SAMPLEFORMAT_INT: if (tif->tif_dir.td_bitspersample<=8) - return(TIFFWriteDirectoryTagSbytePerSample(tif,ndir,dir,tag,(int8)value)); + return(TIFFWriteDirectoryTagSbytePerSample(tif,ndir,dir,tag,(int8_t)value)); else if (tif->tif_dir.td_bitspersample<=16) - return(TIFFWriteDirectoryTagSshortPerSample(tif,ndir,dir,tag,(int16)value)); + return(TIFFWriteDirectoryTagSshortPerSample(tif,ndir,dir,tag,(int16_t)value)); else - return(TIFFWriteDirectoryTagSlongPerSample(tif,ndir,dir,tag,(int32)value)); + return(TIFFWriteDirectoryTagSlongPerSample(tif,ndir,dir,tag,(int32_t)value)); case SAMPLEFORMAT_UINT: if (tif->tif_dir.td_bitspersample<=8) - return(TIFFWriteDirectoryTagBytePerSample(tif,ndir,dir,tag,(uint8)value)); + return(TIFFWriteDirectoryTagBytePerSample(tif,ndir,dir,tag,(uint8_t)value)); else if (tif->tif_dir.td_bitspersample<=16) - return(TIFFWriteDirectoryTagShortPerSample(tif,ndir,dir,tag,(uint16)value)); + return(TIFFWriteDirectoryTagShortPerSample(tif,ndir,dir,tag,(uint16_t)value)); else - return(TIFFWriteDirectoryTagLongPerSample(tif,ndir,dir,tag,(uint32)value)); + return(TIFFWriteDirectoryTagLongPerSample(tif,ndir,dir,tag,(uint32_t)value)); default: return(1); } @@ -1197,7 +1197,7 @@ TIFFWriteDirectoryTagSampleformatPerSample(TIFF* tif, uint32* ndir, TIFFDirEntry #endif static int -TIFFWriteDirectoryTagAscii(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, char* value) +TIFFWriteDirectoryTagAscii(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, char* value) { if (dir==NULL) { @@ -1208,7 +1208,7 @@ TIFFWriteDirectoryTagAscii(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 ta } static int -TIFFWriteDirectoryTagUndefinedArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, uint8* value) +TIFFWriteDirectoryTagUndefinedArray(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, uint8_t* value) { if (dir==NULL) { @@ -1220,7 +1220,7 @@ TIFFWriteDirectoryTagUndefinedArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, #ifdef notdef static int -TIFFWriteDirectoryTagByte(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint8 value) +TIFFWriteDirectoryTagByte(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint8_t value) { if (dir==NULL) { @@ -1232,7 +1232,7 @@ TIFFWriteDirectoryTagByte(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag #endif static int -TIFFWriteDirectoryTagByteArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, uint8* value) +TIFFWriteDirectoryTagByteArray(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, uint8_t* value) { if (dir==NULL) { @@ -1244,19 +1244,19 @@ TIFFWriteDirectoryTagByteArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint1 #if 0 static int -TIFFWriteDirectoryTagBytePerSample(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint8 value) +TIFFWriteDirectoryTagBytePerSample(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint8_t value) { static const char module[] = "TIFFWriteDirectoryTagBytePerSample"; - uint8* m; - uint8* na; - uint16 nb; + uint8_t* m; + uint8_t* na; + uint16_t nb; int o; if (dir==NULL) { (*ndir)++; return(1); } - m=_TIFFmalloc(tif->tif_dir.td_samplesperpixel*sizeof(uint8)); + m=_TIFFmalloc(tif->tif_dir.td_samplesperpixel*sizeof(uint8_t)); if (m==NULL) { TIFFErrorExt(tif->tif_clientdata,module,"Out of memory"); @@ -1272,7 +1272,7 @@ TIFFWriteDirectoryTagBytePerSample(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, u #ifdef notdef static int -TIFFWriteDirectoryTagSbyte(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, int8 value) +TIFFWriteDirectoryTagSbyte(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, int8_t value) { if (dir==NULL) { @@ -1284,7 +1284,7 @@ TIFFWriteDirectoryTagSbyte(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 ta #endif static int -TIFFWriteDirectoryTagSbyteArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, int8* value) +TIFFWriteDirectoryTagSbyteArray(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, int8_t* value) { if (dir==NULL) { @@ -1296,19 +1296,19 @@ TIFFWriteDirectoryTagSbyteArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint #if 0 static int -TIFFWriteDirectoryTagSbytePerSample(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, int8 value) +TIFFWriteDirectoryTagSbytePerSample(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, int8_t value) { static const char module[] = "TIFFWriteDirectoryTagSbytePerSample"; - int8* m; - int8* na; - uint16 nb; + int8_t* m; + int8_t* na; + uint16_t nb; int o; if (dir==NULL) { (*ndir)++; return(1); } - m=_TIFFmalloc(tif->tif_dir.td_samplesperpixel*sizeof(int8)); + m=_TIFFmalloc(tif->tif_dir.td_samplesperpixel*sizeof(int8_t)); if (m==NULL) { TIFFErrorExt(tif->tif_clientdata,module,"Out of memory"); @@ -1323,7 +1323,7 @@ TIFFWriteDirectoryTagSbytePerSample(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, #endif static int -TIFFWriteDirectoryTagShort(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint16 value) +TIFFWriteDirectoryTagShort(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint16_t value) { if (dir==NULL) { @@ -1334,7 +1334,7 @@ TIFFWriteDirectoryTagShort(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 ta } static int -TIFFWriteDirectoryTagShortArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, uint16* value) +TIFFWriteDirectoryTagShortArray(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, uint16_t* value) { if (dir==NULL) { @@ -1345,19 +1345,19 @@ TIFFWriteDirectoryTagShortArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint } static int -TIFFWriteDirectoryTagShortPerSample(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint16 value) +TIFFWriteDirectoryTagShortPerSample(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint16_t value) { static const char module[] = "TIFFWriteDirectoryTagShortPerSample"; - uint16* m; - uint16* na; - uint16 nb; + uint16_t* m; + uint16_t* na; + uint16_t nb; int o; if (dir==NULL) { (*ndir)++; return(1); } - m=_TIFFmalloc(tif->tif_dir.td_samplesperpixel*sizeof(uint16)); + m=_TIFFmalloc(tif->tif_dir.td_samplesperpixel*sizeof(uint16_t)); if (m==NULL) { TIFFErrorExt(tif->tif_clientdata,module,"Out of memory"); @@ -1372,7 +1372,7 @@ TIFFWriteDirectoryTagShortPerSample(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, #ifdef notdef static int -TIFFWriteDirectoryTagSshort(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, int16 value) +TIFFWriteDirectoryTagSshort(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, int16_t value) { if (dir==NULL) { @@ -1384,7 +1384,7 @@ TIFFWriteDirectoryTagSshort(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 t #endif static int -TIFFWriteDirectoryTagSshortArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, int16* value) +TIFFWriteDirectoryTagSshortArray(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, int16_t* value) { if (dir==NULL) { @@ -1396,19 +1396,19 @@ TIFFWriteDirectoryTagSshortArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uin #if 0 static int -TIFFWriteDirectoryTagSshortPerSample(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, int16 value) +TIFFWriteDirectoryTagSshortPerSample(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, int16_t value) { static const char module[] = "TIFFWriteDirectoryTagSshortPerSample"; - int16* m; - int16* na; - uint16 nb; + int16_t* m; + int16_t* na; + uint16_t nb; int o; if (dir==NULL) { (*ndir)++; return(1); } - m=_TIFFmalloc(tif->tif_dir.td_samplesperpixel*sizeof(int16)); + m=_TIFFmalloc(tif->tif_dir.td_samplesperpixel*sizeof(int16_t)); if (m==NULL) { TIFFErrorExt(tif->tif_clientdata,module,"Out of memory"); @@ -1423,7 +1423,7 @@ TIFFWriteDirectoryTagSshortPerSample(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, #endif static int -TIFFWriteDirectoryTagLong(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 value) +TIFFWriteDirectoryTagLong(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t value) { if (dir==NULL) { @@ -1434,7 +1434,7 @@ TIFFWriteDirectoryTagLong(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag } static int -TIFFWriteDirectoryTagLongArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, uint32* value) +TIFFWriteDirectoryTagLongArray(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, uint32_t* value) { if (dir==NULL) { @@ -1446,19 +1446,19 @@ TIFFWriteDirectoryTagLongArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint1 #if 0 static int -TIFFWriteDirectoryTagLongPerSample(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 value) +TIFFWriteDirectoryTagLongPerSample(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t value) { static const char module[] = "TIFFWriteDirectoryTagLongPerSample"; - uint32* m; - uint32* na; - uint16 nb; + uint32_t* m; + uint32_t* na; + uint16_t nb; int o; if (dir==NULL) { (*ndir)++; return(1); } - m=_TIFFmalloc(tif->tif_dir.td_samplesperpixel*sizeof(uint32)); + m=_TIFFmalloc(tif->tif_dir.td_samplesperpixel*sizeof(uint32_t)); if (m==NULL) { TIFFErrorExt(tif->tif_clientdata,module,"Out of memory"); @@ -1474,7 +1474,7 @@ TIFFWriteDirectoryTagLongPerSample(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, u #ifdef notdef static int -TIFFWriteDirectoryTagSlong(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, int32 value) +TIFFWriteDirectoryTagSlong(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, int32_t value) { if (dir==NULL) { @@ -1486,7 +1486,7 @@ TIFFWriteDirectoryTagSlong(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 ta #endif static int -TIFFWriteDirectoryTagSlongArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, int32* value) +TIFFWriteDirectoryTagSlongArray(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, int32_t* value) { if (dir==NULL) { @@ -1498,19 +1498,19 @@ TIFFWriteDirectoryTagSlongArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint #if 0 static int -TIFFWriteDirectoryTagSlongPerSample(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, int32 value) +TIFFWriteDirectoryTagSlongPerSample(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, int32_t value) { static const char module[] = "TIFFWriteDirectoryTagSlongPerSample"; - int32* m; - int32* na; - uint16 nb; + int32_t* m; + int32_t* na; + uint16_t nb; int o; if (dir==NULL) { (*ndir)++; return(1); } - m=_TIFFmalloc(tif->tif_dir.td_samplesperpixel*sizeof(int32)); + m=_TIFFmalloc(tif->tif_dir.td_samplesperpixel*sizeof(int32_t)); if (m==NULL) { TIFFErrorExt(tif->tif_clientdata,module,"Out of memory"); @@ -1526,7 +1526,7 @@ TIFFWriteDirectoryTagSlongPerSample(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, #ifdef notdef static int -TIFFWriteDirectoryTagLong8(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint64 value) +TIFFWriteDirectoryTagLong8(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint64_t value) { if (dir==NULL) { @@ -1538,7 +1538,7 @@ TIFFWriteDirectoryTagLong8(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 ta #endif static int -TIFFWriteDirectoryTagLong8Array(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, uint64* value) +TIFFWriteDirectoryTagLong8Array(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, uint64_t* value) { if (dir==NULL) { @@ -1550,7 +1550,7 @@ TIFFWriteDirectoryTagLong8Array(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint #ifdef notdef static int -TIFFWriteDirectoryTagSlong8(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, int64 value) +TIFFWriteDirectoryTagSlong8(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, int64_t value) { if (dir==NULL) { @@ -1562,7 +1562,7 @@ TIFFWriteDirectoryTagSlong8(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 t #endif static int -TIFFWriteDirectoryTagSlong8Array(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, int64* value) +TIFFWriteDirectoryTagSlong8Array(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, int64_t* value) { if (dir==NULL) { @@ -1573,7 +1573,7 @@ TIFFWriteDirectoryTagSlong8Array(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uin } static int -TIFFWriteDirectoryTagRational(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, double value) +TIFFWriteDirectoryTagRational(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, double value) { if (dir==NULL) { @@ -1584,7 +1584,7 @@ TIFFWriteDirectoryTagRational(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 } static int -TIFFWriteDirectoryTagRationalArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, float* value) +TIFFWriteDirectoryTagRationalArray(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, float* value) { if (dir==NULL) { @@ -1595,7 +1595,7 @@ TIFFWriteDirectoryTagRationalArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, u } static int -TIFFWriteDirectoryTagSrationalArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, float* value) +TIFFWriteDirectoryTagSrationalArray(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, float* value) { if (dir==NULL) { @@ -1607,7 +1607,7 @@ TIFFWriteDirectoryTagSrationalArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, /*-- Rational2Double: additional write functions */ static int -TIFFWriteDirectoryTagRationalDoubleArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, double* value) +TIFFWriteDirectoryTagRationalDoubleArray(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, double* value) { if (dir==NULL) { @@ -1618,7 +1618,7 @@ TIFFWriteDirectoryTagRationalDoubleArray(TIFF* tif, uint32* ndir, TIFFDirEntry* } static int -TIFFWriteDirectoryTagSrationalDoubleArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, double* value) +TIFFWriteDirectoryTagSrationalDoubleArray(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, double* value) { if (dir==NULL) { @@ -1629,7 +1629,7 @@ TIFFWriteDirectoryTagSrationalDoubleArray(TIFF* tif, uint32* ndir, TIFFDirEntry* } #ifdef notdef -static int TIFFWriteDirectoryTagFloat(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, float value) +static int TIFFWriteDirectoryTagFloat(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, float value) { if (dir==NULL) { @@ -1640,7 +1640,7 @@ static int TIFFWriteDirectoryTagFloat(TIFF* tif, uint32* ndir, TIFFDirEntry* dir } #endif -static int TIFFWriteDirectoryTagFloatArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, float* value) +static int TIFFWriteDirectoryTagFloatArray(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, float* value) { if (dir==NULL) { @@ -1651,12 +1651,12 @@ static int TIFFWriteDirectoryTagFloatArray(TIFF* tif, uint32* ndir, TIFFDirEntry } #if 0 -static int TIFFWriteDirectoryTagFloatPerSample(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, float value) +static int TIFFWriteDirectoryTagFloatPerSample(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, float value) { static const char module[] = "TIFFWriteDirectoryTagFloatPerSample"; float* m; float* na; - uint16 nb; + uint16_t nb; int o; if (dir==NULL) { @@ -1678,7 +1678,7 @@ static int TIFFWriteDirectoryTagFloatPerSample(TIFF* tif, uint32* ndir, TIFFDirE #endif #ifdef notdef -static int TIFFWriteDirectoryTagDouble(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, double value) +static int TIFFWriteDirectoryTagDouble(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, double value) { if (dir==NULL) { @@ -1689,7 +1689,7 @@ static int TIFFWriteDirectoryTagDouble(TIFF* tif, uint32* ndir, TIFFDirEntry* di } #endif -static int TIFFWriteDirectoryTagDoubleArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, double* value) +static int TIFFWriteDirectoryTagDoubleArray(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, double* value) { if (dir==NULL) { @@ -1700,12 +1700,12 @@ static int TIFFWriteDirectoryTagDoubleArray(TIFF* tif, uint32* ndir, TIFFDirEntr } #if 0 -static int TIFFWriteDirectoryTagDoublePerSample(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, double value) +static int TIFFWriteDirectoryTagDoublePerSample(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, double value) { static const char module[] = "TIFFWriteDirectoryTagDoublePerSample"; double* m; double* na; - uint16 nb; + uint16_t nb; int o; if (dir==NULL) { @@ -1727,7 +1727,7 @@ static int TIFFWriteDirectoryTagDoublePerSample(TIFF* tif, uint32* ndir, TIFFDir #endif static int -TIFFWriteDirectoryTagIfdArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, uint32* value) +TIFFWriteDirectoryTagIfdArray(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, uint32_t* value) { if (dir==NULL) { @@ -1739,7 +1739,7 @@ TIFFWriteDirectoryTagIfdArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 #ifdef notdef static int -TIFFWriteDirectoryTagIfd8Array(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, uint64* value) +TIFFWriteDirectoryTagIfd8Array(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, uint64_t* value) { if (dir==NULL) { @@ -1751,7 +1751,7 @@ TIFFWriteDirectoryTagIfd8Array(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint1 #endif static int -TIFFWriteDirectoryTagShortLong(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 value) +TIFFWriteDirectoryTagShortLong(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t value) { if (dir==NULL) { @@ -1759,14 +1759,14 @@ TIFFWriteDirectoryTagShortLong(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint1 return(1); } if (value<=0xFFFF) - return(TIFFWriteDirectoryTagCheckedShort(tif,ndir,dir,tag,(uint16)value)); + return(TIFFWriteDirectoryTagCheckedShort(tif,ndir,dir,tag,(uint16_t)value)); else return(TIFFWriteDirectoryTagCheckedLong(tif,ndir,dir,tag,value)); } -static int _WriteAsType(TIFF* tif, uint64 strile_size, uint64 uncompressed_threshold) +static int _WriteAsType(TIFF* tif, uint64_t strile_size, uint64_t uncompressed_threshold) { - const uint16 compression = tif->tif_dir.td_compression; + const uint16_t compression = tif->tif_dir.td_compression; if ( compression == COMPRESSION_NONE ) { return strile_size > uncompressed_threshold; @@ -1787,12 +1787,12 @@ static int _WriteAsType(TIFF* tif, uint64 strile_size, uint64 uncompressed_thres return 1; } -static int WriteAsLong8(TIFF* tif, uint64 strile_size) +static int WriteAsLong8(TIFF* tif, uint64_t strile_size) { return _WriteAsType(tif, strile_size, 0xFFFFFFFFU); } -static int WriteAsLong4(TIFF* tif, uint64 strile_size) +static int WriteAsLong4(TIFF* tif, uint64_t strile_size) { return _WriteAsType(tif, strile_size, 0xFFFFU); } @@ -1805,7 +1805,7 @@ static int WriteAsLong4(TIFF* tif, uint64 strile_size) /************************************************************************/ static int -TIFFWriteDirectoryTagLongLong8Array(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, uint64* value) +TIFFWriteDirectoryTagLongLong8Array(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, uint64_t* value) { static const char module[] = "TIFFWriteDirectoryTagLongLong8Array"; int o; @@ -1862,10 +1862,10 @@ TIFFWriteDirectoryTagLongLong8Array(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, ** and convert to long format. */ - uint32* p = _TIFFmalloc(count*sizeof(uint32)); - uint32* q; - uint64* ma; - uint32 mb; + uint32_t* p = _TIFFmalloc(count * sizeof(uint32_t)); + uint32_t* q; + uint64_t* ma; + uint32_t mb; if (p==NULL) { @@ -1882,7 +1882,7 @@ TIFFWriteDirectoryTagLongLong8Array(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, _TIFFfree(p); return(0); } - *q= (uint32)(*ma); + *q= (uint32_t)(*ma); } o=TIFFWriteDirectoryTagCheckedLongArray(tif,ndir,dir,tag,count,p); @@ -1890,10 +1890,10 @@ TIFFWriteDirectoryTagLongLong8Array(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, } else { - uint16* p = _TIFFmalloc(count*sizeof(uint16)); - uint16* q; - uint64* ma; - uint32 mb; + uint16_t* p = _TIFFmalloc(count * sizeof(uint16_t)); + uint16_t* q; + uint64_t* ma; + uint32_t mb; if (p==NULL) { @@ -1911,7 +1911,7 @@ TIFFWriteDirectoryTagLongLong8Array(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, _TIFFfree(p); return(0); } - *q= (uint16)(*ma); + *q= (uint16_t)(*ma); } o=TIFFWriteDirectoryTagCheckedShortArray(tif,ndir,dir,tag,count,p); @@ -1928,13 +1928,13 @@ TIFFWriteDirectoryTagLongLong8Array(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, /************************************************************************/ static int -TIFFWriteDirectoryTagIfdIfd8Array(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, uint64* value) +TIFFWriteDirectoryTagIfdIfd8Array(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, uint64_t* value) { static const char module[] = "TIFFWriteDirectoryTagIfdIfd8Array"; - uint64* ma; - uint32 mb; - uint32* p; - uint32* q; + uint64_t* ma; + uint32_t mb; + uint32_t* p; + uint32_t* q; int o; /* is this just a counting pass? */ @@ -1954,7 +1954,7 @@ TIFFWriteDirectoryTagIfdIfd8Array(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, ui ** and convert to long format. */ - p = _TIFFmalloc(count*sizeof(uint32)); + p = _TIFFmalloc(count*sizeof(uint32_t)); if (p==NULL) { TIFFErrorExt(tif->tif_clientdata,module,"Out of memory"); @@ -1970,7 +1970,7 @@ TIFFWriteDirectoryTagIfdIfd8Array(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, ui _TIFFfree(p); return(0); } - *q= (uint32)(*ma); + *q= (uint32_t)(*ma); } o=TIFFWriteDirectoryTagCheckedIfdArray(tif,ndir,dir,tag,count,p); @@ -1981,12 +1981,12 @@ TIFFWriteDirectoryTagIfdIfd8Array(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, ui #ifdef notdef static int -TIFFWriteDirectoryTagShortLongLong8Array(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, uint64* value) +TIFFWriteDirectoryTagShortLongLong8Array(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, uint64_t* value) { static const char module[] = "TIFFWriteDirectoryTagShortLongLong8Array"; - uint64* ma; - uint32 mb; - uint8 n; + uint64_t* ma; + uint32_t mb; + uint8_t n; int o; if (dir==NULL) { @@ -2006,31 +2006,31 @@ TIFFWriteDirectoryTagShortLongLong8Array(TIFF* tif, uint32* ndir, TIFFDirEntry* } if (n==0) { - uint16* p; - uint16* q; - p=_TIFFmalloc(count*sizeof(uint16)); + uint16_t* p; + uint16_t* q; + p=_TIFFmalloc(count*sizeof(uint16_t)); if (p==NULL) { TIFFErrorExt(tif->tif_clientdata,module,"Out of memory"); return(0); } for (ma=value, mb=0, q=p; mb<count; ma++, mb++, q++) - *q=(uint16)(*ma); + *q=(uint16_t)(*ma); o=TIFFWriteDirectoryTagCheckedShortArray(tif,ndir,dir,tag,count,p); _TIFFfree(p); } else if (n==1) { - uint32* p; - uint32* q; - p=_TIFFmalloc(count*sizeof(uint32)); + uint32_t* p; + uint32_t* q; + p=_TIFFmalloc(count*sizeof(uint32_t)); if (p==NULL) { TIFFErrorExt(tif->tif_clientdata,module,"Out of memory"); return(0); } for (ma=value, mb=0, q=p; mb<count; ma++, mb++, q++) - *q=(uint32)(*ma); + *q=(uint32_t)(*ma); o=TIFFWriteDirectoryTagCheckedLongArray(tif,ndir,dir,tag,count,p); _TIFFfree(p); } @@ -2043,11 +2043,11 @@ TIFFWriteDirectoryTagShortLongLong8Array(TIFF* tif, uint32* ndir, TIFFDirEntry* } #endif static int -TIFFWriteDirectoryTagColormap(TIFF* tif, uint32* ndir, TIFFDirEntry* dir) +TIFFWriteDirectoryTagColormap(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir) { static const char module[] = "TIFFWriteDirectoryTagColormap"; - uint32 m; - uint16* n; + uint32_t m; + uint16_t* n; int o; if (dir==NULL) { @@ -2055,27 +2055,27 @@ TIFFWriteDirectoryTagColormap(TIFF* tif, uint32* ndir, TIFFDirEntry* dir) return(1); } m=(1<<tif->tif_dir.td_bitspersample); - n=_TIFFmalloc(3*m*sizeof(uint16)); + n=_TIFFmalloc(3*m*sizeof(uint16_t)); if (n==NULL) { TIFFErrorExt(tif->tif_clientdata,module,"Out of memory"); return(0); } - _TIFFmemcpy(&n[0],tif->tif_dir.td_colormap[0],m*sizeof(uint16)); - _TIFFmemcpy(&n[m],tif->tif_dir.td_colormap[1],m*sizeof(uint16)); - _TIFFmemcpy(&n[2*m],tif->tif_dir.td_colormap[2],m*sizeof(uint16)); + _TIFFmemcpy(&n[0],tif->tif_dir.td_colormap[0],m*sizeof(uint16_t)); + _TIFFmemcpy(&n[m],tif->tif_dir.td_colormap[1],m*sizeof(uint16_t)); + _TIFFmemcpy(&n[2*m],tif->tif_dir.td_colormap[2],m*sizeof(uint16_t)); o=TIFFWriteDirectoryTagCheckedShortArray(tif,ndir,dir,TIFFTAG_COLORMAP,3*m,n); _TIFFfree(n); return(o); } static int -TIFFWriteDirectoryTagTransferfunction(TIFF* tif, uint32* ndir, TIFFDirEntry* dir) +TIFFWriteDirectoryTagTransferfunction(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir) { static const char module[] = "TIFFWriteDirectoryTagTransferfunction"; - uint32 m; - uint16 n; - uint16* o; + uint32_t m; + uint16_t n; + uint16_t* o; int p; if (dir==NULL) { @@ -2095,38 +2095,38 @@ TIFFWriteDirectoryTagTransferfunction(TIFF* tif, uint32* ndir, TIFFDirEntry* dir if (n==3) { if (tif->tif_dir.td_transferfunction[2] == NULL || - !_TIFFmemcmp(tif->tif_dir.td_transferfunction[0],tif->tif_dir.td_transferfunction[2],m*sizeof(uint16))) + !_TIFFmemcmp(tif->tif_dir.td_transferfunction[0],tif->tif_dir.td_transferfunction[2],m*sizeof(uint16_t))) n=2; } if (n==2) { if (tif->tif_dir.td_transferfunction[1] == NULL || - !_TIFFmemcmp(tif->tif_dir.td_transferfunction[0],tif->tif_dir.td_transferfunction[1],m*sizeof(uint16))) + !_TIFFmemcmp(tif->tif_dir.td_transferfunction[0],tif->tif_dir.td_transferfunction[1],m*sizeof(uint16_t))) n=1; } if (n==0) n=1; - o=_TIFFmalloc(n*m*sizeof(uint16)); + o=_TIFFmalloc(n*m*sizeof(uint16_t)); if (o==NULL) { TIFFErrorExt(tif->tif_clientdata,module,"Out of memory"); return(0); } - _TIFFmemcpy(&o[0],tif->tif_dir.td_transferfunction[0],m*sizeof(uint16)); + _TIFFmemcpy(&o[0],tif->tif_dir.td_transferfunction[0],m*sizeof(uint16_t)); if (n>1) - _TIFFmemcpy(&o[m],tif->tif_dir.td_transferfunction[1],m*sizeof(uint16)); + _TIFFmemcpy(&o[m],tif->tif_dir.td_transferfunction[1],m*sizeof(uint16_t)); if (n>2) - _TIFFmemcpy(&o[2*m],tif->tif_dir.td_transferfunction[2],m*sizeof(uint16)); + _TIFFmemcpy(&o[2*m],tif->tif_dir.td_transferfunction[2],m*sizeof(uint16_t)); p=TIFFWriteDirectoryTagCheckedShortArray(tif,ndir,dir,TIFFTAG_TRANSFERFUNCTION,n*m,o); _TIFFfree(o); return(p); } static int -TIFFWriteDirectoryTagSubifd(TIFF* tif, uint32* ndir, TIFFDirEntry* dir) +TIFFWriteDirectoryTagSubifd(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir) { static const char module[] = "TIFFWriteDirectoryTagSubifd"; - uint64 m; + uint64_t m; int n; if (tif->tif_dir.td_nsubifd==0) return(1); @@ -2138,11 +2138,11 @@ TIFFWriteDirectoryTagSubifd(TIFF* tif, uint32* ndir, TIFFDirEntry* dir) m=tif->tif_dataoff; if (!(tif->tif_flags&TIFF_BIGTIFF)) { - uint32* o; - uint64* pa; - uint32* pb; - uint16 p; - o=_TIFFmalloc(tif->tif_dir.td_nsubifd*sizeof(uint32)); + uint32_t* o; + uint64_t* pa; + uint32_t* pb; + uint16_t p; + o=_TIFFmalloc(tif->tif_dir.td_nsubifd*sizeof(uint32_t)); if (o==NULL) { TIFFErrorExt(tif->tif_clientdata,module,"Out of memory"); @@ -2161,7 +2161,7 @@ TIFFWriteDirectoryTagSubifd(TIFF* tif, uint32* ndir, TIFFDirEntry* dir) _TIFFfree(o); return(0); } - *pb++=(uint32)(*pa++); + *pb++=(uint32_t)(*pa++); } n=TIFFWriteDirectoryTagCheckedIfdArray(tif,ndir,dir,TIFFTAG_SUBIFD,tif->tif_dir.td_nsubifd,o); _TIFFfree(o); @@ -2188,56 +2188,56 @@ TIFFWriteDirectoryTagSubifd(TIFF* tif, uint32* ndir, TIFFDirEntry* dir) } static int -TIFFWriteDirectoryTagCheckedAscii(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, char* value) +TIFFWriteDirectoryTagCheckedAscii(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, char* value) { assert(sizeof(char)==1); return(TIFFWriteDirectoryTagData(tif,ndir,dir,tag,TIFF_ASCII,count,count,value)); } static int -TIFFWriteDirectoryTagCheckedUndefinedArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, uint8* value) +TIFFWriteDirectoryTagCheckedUndefinedArray(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, uint8_t* value) { - assert(sizeof(uint8)==1); + assert(sizeof(uint8_t) == 1); return(TIFFWriteDirectoryTagData(tif,ndir,dir,tag,TIFF_UNDEFINED,count,count,value)); } #ifdef notdef static int -TIFFWriteDirectoryTagCheckedByte(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint8 value) +TIFFWriteDirectoryTagCheckedByte(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint8_t value) { - assert(sizeof(uint8)==1); + assert(sizeof(uint8_t)==1); return(TIFFWriteDirectoryTagData(tif,ndir,dir,tag,TIFF_BYTE,1,1,&value)); } #endif static int -TIFFWriteDirectoryTagCheckedByteArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, uint8* value) +TIFFWriteDirectoryTagCheckedByteArray(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, uint8_t* value) { - assert(sizeof(uint8)==1); + assert(sizeof(uint8_t) == 1); return(TIFFWriteDirectoryTagData(tif,ndir,dir,tag,TIFF_BYTE,count,count,value)); } #ifdef notdef static int -TIFFWriteDirectoryTagCheckedSbyte(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, int8 value) +TIFFWriteDirectoryTagCheckedSbyte(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, int8_t value) { - assert(sizeof(int8)==1); + assert(sizeof(int8_t)==1); return(TIFFWriteDirectoryTagData(tif,ndir,dir,tag,TIFF_SBYTE,1,1,&value)); } #endif static int -TIFFWriteDirectoryTagCheckedSbyteArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, int8* value) +TIFFWriteDirectoryTagCheckedSbyteArray(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, int8_t* value) { - assert(sizeof(int8)==1); + assert(sizeof(int8_t) == 1); return(TIFFWriteDirectoryTagData(tif,ndir,dir,tag,TIFF_SBYTE,count,count,value)); } static int -TIFFWriteDirectoryTagCheckedShort(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint16 value) +TIFFWriteDirectoryTagCheckedShort(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint16_t value) { - uint16 m; - assert(sizeof(uint16)==2); + uint16_t m; + assert(sizeof(uint16_t) == 2); m=value; if (tif->tif_flags&TIFF_SWAB) TIFFSwabShort(&m); @@ -2245,10 +2245,10 @@ TIFFWriteDirectoryTagCheckedShort(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, ui } static int -TIFFWriteDirectoryTagCheckedShortArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, uint16* value) +TIFFWriteDirectoryTagCheckedShortArray(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, uint16_t* value) { assert(count<0x80000000); - assert(sizeof(uint16)==2); + assert(sizeof(uint16_t) == 2); if (tif->tif_flags&TIFF_SWAB) TIFFSwabArrayOfShort(value,count); return(TIFFWriteDirectoryTagData(tif,ndir,dir,tag,TIFF_SHORT,count,count*2,value)); @@ -2256,32 +2256,32 @@ TIFFWriteDirectoryTagCheckedShortArray(TIFF* tif, uint32* ndir, TIFFDirEntry* di #ifdef notdef static int -TIFFWriteDirectoryTagCheckedSshort(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, int16 value) +TIFFWriteDirectoryTagCheckedSshort(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, int16_t value) { - int16 m; - assert(sizeof(int16)==2); + int16_t m; + assert(sizeof(int16_t)==2); m=value; if (tif->tif_flags&TIFF_SWAB) - TIFFSwabShort((uint16*)(&m)); + TIFFSwabShort((uint16_t*)(&m)); return(TIFFWriteDirectoryTagData(tif,ndir,dir,tag,TIFF_SSHORT,1,2,&m)); } #endif static int -TIFFWriteDirectoryTagCheckedSshortArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, int16* value) +TIFFWriteDirectoryTagCheckedSshortArray(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, int16_t* value) { assert(count<0x80000000); - assert(sizeof(int16)==2); + assert(sizeof(int16_t) == 2); if (tif->tif_flags&TIFF_SWAB) - TIFFSwabArrayOfShort((uint16*)value,count); + TIFFSwabArrayOfShort((uint16_t*)value, count); return(TIFFWriteDirectoryTagData(tif,ndir,dir,tag,TIFF_SSHORT,count,count*2,value)); } static int -TIFFWriteDirectoryTagCheckedLong(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 value) +TIFFWriteDirectoryTagCheckedLong(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t value) { - uint32 m; - assert(sizeof(uint32)==4); + uint32_t m; + assert(sizeof(uint32_t) == 4); m=value; if (tif->tif_flags&TIFF_SWAB) TIFFSwabLong(&m); @@ -2289,10 +2289,10 @@ TIFFWriteDirectoryTagCheckedLong(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uin } static int -TIFFWriteDirectoryTagCheckedLongArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, uint32* value) +TIFFWriteDirectoryTagCheckedLongArray(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, uint32_t* value) { assert(count<0x40000000); - assert(sizeof(uint32)==4); + assert(sizeof(uint32_t) == 4); if (tif->tif_flags&TIFF_SWAB) TIFFSwabArrayOfLong(value,count); return(TIFFWriteDirectoryTagData(tif,ndir,dir,tag,TIFF_LONG,count,count*4,value)); @@ -2300,33 +2300,33 @@ TIFFWriteDirectoryTagCheckedLongArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir #ifdef notdef static int -TIFFWriteDirectoryTagCheckedSlong(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, int32 value) +TIFFWriteDirectoryTagCheckedSlong(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, int32_t value) { - int32 m; - assert(sizeof(int32)==4); + int32_t m; + assert(sizeof(int32_t)==4); m=value; if (tif->tif_flags&TIFF_SWAB) - TIFFSwabLong((uint32*)(&m)); + TIFFSwabLong((uint32_t*)(&m)); return(TIFFWriteDirectoryTagData(tif,ndir,dir,tag,TIFF_SLONG,1,4,&m)); } #endif static int -TIFFWriteDirectoryTagCheckedSlongArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, int32* value) +TIFFWriteDirectoryTagCheckedSlongArray(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, int32_t* value) { assert(count<0x40000000); - assert(sizeof(int32)==4); + assert(sizeof(int32_t) == 4); if (tif->tif_flags&TIFF_SWAB) - TIFFSwabArrayOfLong((uint32*)value,count); + TIFFSwabArrayOfLong((uint32_t*)value, count); return(TIFFWriteDirectoryTagData(tif,ndir,dir,tag,TIFF_SLONG,count,count*4,value)); } #ifdef notdef static int -TIFFWriteDirectoryTagCheckedLong8(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint64 value) +TIFFWriteDirectoryTagCheckedLong8(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint64_t value) { - uint64 m; - assert(sizeof(uint64)==8); + uint64_t m; + assert(sizeof(uint64_t)==8); if( !(tif->tif_flags&TIFF_BIGTIFF) ) { TIFFErrorExt(tif->tif_clientdata,"TIFFWriteDirectoryTagCheckedLong8","LONG8 not allowed for ClassicTIFF"); return(0); @@ -2339,10 +2339,10 @@ TIFFWriteDirectoryTagCheckedLong8(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, ui #endif static int -TIFFWriteDirectoryTagCheckedLong8Array(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, uint64* value) +TIFFWriteDirectoryTagCheckedLong8Array(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, uint64_t* value) { assert(count<0x20000000); - assert(sizeof(uint64)==8); + assert(sizeof(uint64_t) == 8); if( !(tif->tif_flags&TIFF_BIGTIFF) ) { TIFFErrorExt(tif->tif_clientdata,"TIFFWriteDirectoryTagCheckedLong8Array","LONG8 not allowed for ClassicTIFF"); return(0); @@ -2354,41 +2354,41 @@ TIFFWriteDirectoryTagCheckedLong8Array(TIFF* tif, uint32* ndir, TIFFDirEntry* di #ifdef notdef static int -TIFFWriteDirectoryTagCheckedSlong8(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, int64 value) +TIFFWriteDirectoryTagCheckedSlong8(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, int64_t value) { - int64 m; - assert(sizeof(int64)==8); + int64_t m; + assert(sizeof(int64_t)==8); if( !(tif->tif_flags&TIFF_BIGTIFF) ) { TIFFErrorExt(tif->tif_clientdata,"TIFFWriteDirectoryTagCheckedSlong8","SLONG8 not allowed for ClassicTIFF"); return(0); } m=value; if (tif->tif_flags&TIFF_SWAB) - TIFFSwabLong8((uint64*)(&m)); + TIFFSwabLong8((uint64_t*)(&m)); return(TIFFWriteDirectoryTagData(tif,ndir,dir,tag,TIFF_SLONG8,1,8,&m)); } #endif static int -TIFFWriteDirectoryTagCheckedSlong8Array(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, int64* value) +TIFFWriteDirectoryTagCheckedSlong8Array(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, int64_t* value) { assert(count<0x20000000); - assert(sizeof(int64)==8); + assert(sizeof(int64_t) == 8); if( !(tif->tif_flags&TIFF_BIGTIFF) ) { TIFFErrorExt(tif->tif_clientdata,"TIFFWriteDirectoryTagCheckedSlong8Array","SLONG8 not allowed for ClassicTIFF"); return(0); } if (tif->tif_flags&TIFF_SWAB) - TIFFSwabArrayOfLong8((uint64*)value,count); + TIFFSwabArrayOfLong8((uint64_t*)value, count); return(TIFFWriteDirectoryTagData(tif,ndir,dir,tag,TIFF_SLONG8,count,count*8,value)); } static int -TIFFWriteDirectoryTagCheckedRational(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, double value) +TIFFWriteDirectoryTagCheckedRational(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, double value) { static const char module[] = "TIFFWriteDirectoryTagCheckedRational"; - uint32 m[2]; - assert(sizeof(uint32)==4); + uint32_t m[2]; + assert(sizeof(uint32_t) == 4); if (value < 0) { TIFFErrorExt(tif->tif_clientdata, module, "Negative value is illegal"); @@ -2405,20 +2405,20 @@ TIFFWriteDirectoryTagCheckedRational(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, m[0]=0; m[1]=1; } - else if (value <= 0xFFFFFFFFU && value==(double)(uint32)value) + else if (value <= 0xFFFFFFFFU && value==(double)(uint32_t)value) { - m[0]=(uint32)value; + m[0]=(uint32_t)value; m[1]=1; } else if (value<1.0) { - m[0]=(uint32)(value*0xFFFFFFFF); + m[0]=(uint32_t)(value*0xFFFFFFFF); m[1]=0xFFFFFFFF; } else { m[0]=0xFFFFFFFF; - m[1]=(uint32)(0xFFFFFFFF/value); + m[1]=(uint32_t)(0xFFFFFFFF/value); } #else /*--Rational2Double: New function also used for non-custom rational tags. @@ -2438,16 +2438,16 @@ TIFFWriteDirectoryTagCheckedRational(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, } static int -TIFFWriteDirectoryTagCheckedRationalArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, float* value) +TIFFWriteDirectoryTagCheckedRationalArray(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, float* value) { static const char module[] = "TIFFWriteDirectoryTagCheckedRationalArray"; - uint32* m; + uint32_t* m; float* na; - uint32* nb; - uint32 nc; + uint32_t* nb; + uint32_t nc; int o; - assert(sizeof(uint32)==4); - m=_TIFFmalloc(count*2*sizeof(uint32)); + assert(sizeof(uint32_t) == 4); + m=_TIFFmalloc(count*2*sizeof(uint32_t)); if (m==NULL) { TIFFErrorExt(tif->tif_clientdata,module,"Out of memory"); @@ -2462,20 +2462,20 @@ TIFFWriteDirectoryTagCheckedRationalArray(TIFF* tif, uint32* ndir, TIFFDirEntry* nb[1]=1; } else if (*na >= 0 && *na <= (float)0xFFFFFFFFU && - *na==(float)(uint32)(*na)) + *na==(float)(uint32_t)(*na)) { - nb[0]=(uint32)(*na); + nb[0]=(uint32_t)(*na); nb[1]=1; } else if (*na<1.0) { - nb[0]=(uint32)((double)(*na)*0xFFFFFFFF); + nb[0]=(uint32_t)((double)(*na)*0xFFFFFFFF); nb[1]=0xFFFFFFFF; } else { nb[0]=0xFFFFFFFF; - nb[1]=(uint32)((double)0xFFFFFFFF/(*na)); + nb[1]=(uint32_t)((double)0xFFFFFFFF/(*na)); } #else /*-- Rational2Double: Also for float precision accuracy is sometimes enhanced --*/ @@ -2490,16 +2490,16 @@ TIFFWriteDirectoryTagCheckedRationalArray(TIFF* tif, uint32* ndir, TIFFDirEntry* } static int -TIFFWriteDirectoryTagCheckedSrationalArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, float* value) +TIFFWriteDirectoryTagCheckedSrationalArray(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, float* value) { static const char module[] = "TIFFWriteDirectoryTagCheckedSrationalArray"; - int32* m; + int32_t* m; float* na; - int32* nb; - uint32 nc; + int32_t* nb; + uint32_t nc; int o; - assert(sizeof(int32)==4); - m=_TIFFmalloc(count*2*sizeof(int32)); + assert(sizeof(int32_t) == 4); + m=_TIFFmalloc(count*2*sizeof(int32_t)); if (m==NULL) { TIFFErrorExt(tif->tif_clientdata,module,"Out of memory"); @@ -2510,38 +2510,38 @@ TIFFWriteDirectoryTagCheckedSrationalArray(TIFF* tif, uint32* ndir, TIFFDirEntry #ifdef not_def if (*na<0.0) { - if (*na==(int32)(*na)) + if (*na==(int32_t)(*na)) { - nb[0]=(int32)(*na); + nb[0]=(int32_t)(*na); nb[1]=1; } else if (*na>-1.0) { - nb[0]=-(int32)((double)(-*na)*0x7FFFFFFF); + nb[0]=-(int32_t)((double)(-*na)*0x7FFFFFFF); nb[1]=0x7FFFFFFF; } else { nb[0]=-0x7FFFFFFF; - nb[1]=(int32)((double)0x7FFFFFFF/(-*na)); + nb[1]=(int32_t)((double)0x7FFFFFFF/(-*na)); } } else { - if (*na==(int32)(*na)) + if (*na==(int32_t)(*na)) { - nb[0]=(int32)(*na); + nb[0]=(int32_t)(*na); nb[1]=1; } else if (*na<1.0) { - nb[0]=(int32)((double)(*na)*0x7FFFFFFF); + nb[0]=(int32_t)((double)(*na)*0x7FFFFFFF); nb[1]=0x7FFFFFFF; } else { nb[0]=0x7FFFFFFF; - nb[1]=(int32)((double)0x7FFFFFFF/(*na)); + nb[1]=(int32_t)((double)0x7FFFFFFF/(*na)); } } #else @@ -2550,7 +2550,7 @@ TIFFWriteDirectoryTagCheckedSrationalArray(TIFF* tif, uint32* ndir, TIFFDirEntry #endif } if (tif->tif_flags&TIFF_SWAB) - TIFFSwabArrayOfLong((uint32*)m,count*2); + TIFFSwabArrayOfLong((uint32_t*)m, count * 2); o=TIFFWriteDirectoryTagData(tif,ndir,dir,tag,TIFF_SRATIONAL,count,count*8,&m[0]); _TIFFfree(m); return(o); @@ -2558,16 +2558,16 @@ TIFFWriteDirectoryTagCheckedSrationalArray(TIFF* tif, uint32* ndir, TIFFDirEntry /*-- Rational2Double: additional write functions for double arrays */ static int -TIFFWriteDirectoryTagCheckedRationalDoubleArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, double* value) +TIFFWriteDirectoryTagCheckedRationalDoubleArray(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, double* value) { static const char module[] = "TIFFWriteDirectoryTagCheckedRationalDoubleArray"; - uint32* m; + uint32_t* m; double* na; - uint32* nb; - uint32 nc; + uint32_t* nb; + uint32_t nc; int o; - assert(sizeof(uint32)==4); - m=_TIFFmalloc(count*2*sizeof(uint32)); + assert(sizeof(uint32_t) == 4); + m=_TIFFmalloc(count*2*sizeof(uint32_t)); if (m==NULL) { TIFFErrorExt(tif->tif_clientdata,module,"Out of memory"); @@ -2585,16 +2585,16 @@ TIFFWriteDirectoryTagCheckedRationalDoubleArray(TIFF* tif, uint32* ndir, TIFFDir } /*-- TIFFWriteDirectoryTagCheckedRationalDoubleArray() ------- */ static int -TIFFWriteDirectoryTagCheckedSrationalDoubleArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, double* value) +TIFFWriteDirectoryTagCheckedSrationalDoubleArray(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, double* value) { static const char module[] = "TIFFWriteDirectoryTagCheckedSrationalDoubleArray"; - int32* m; + int32_t* m; double* na; - int32* nb; - uint32 nc; + int32_t* nb; + uint32_t nc; int o; - assert(sizeof(int32)==4); - m=_TIFFmalloc(count*2*sizeof(int32)); + assert(sizeof(int32_t) == 4); + m=_TIFFmalloc(count*2*sizeof(int32_t)); if (m==NULL) { TIFFErrorExt(tif->tif_clientdata,module,"Out of memory"); @@ -2605,7 +2605,7 @@ TIFFWriteDirectoryTagCheckedSrationalDoubleArray(TIFF* tif, uint32* ndir, TIFFDi DoubleToSrational(*na, &nb[0], &nb[1]); } if (tif->tif_flags&TIFF_SWAB) - TIFFSwabArrayOfLong((uint32*)m,count*2); + TIFFSwabArrayOfLong((uint32_t*)m, count * 2); o=TIFFWriteDirectoryTagData(tif,ndir,dir,tag,TIFF_SRATIONAL,count,count*8,&m[0]); _TIFFfree(m); return(o); @@ -2626,20 +2626,20 @@ void DoubleToRational_direct(double value, unsigned long *num, unsigned long *de *num=0; *denom=1; } - else if (value <= 0xFFFFFFFFU && (value==(double)(uint32)(value))) /* check for integer values */ + else if (value <= 0xFFFFFFFFU && (value==(double)(uint32_t)(value))) /* check for integer values */ { - *num=(uint32)(value); + *num=(uint32_t)(value); *denom=1; } else if (value<1.0) { - *num = (uint32)((value) * (double)0xFFFFFFFFU); + *num = (uint32_t)((value) * (double)0xFFFFFFFFU); *denom=0xFFFFFFFFU; } else { *num=0xFFFFFFFFU; - *denom=(uint32)((double)0xFFFFFFFFU/(value)); + *denom=(uint32_t)((double)0xFFFFFFFFU/(value)); } } /*-- DoubleToRational_direct() -------------- */ #endif @@ -2656,38 +2656,38 @@ void DoubleToSrational_direct(double value, long *num, long *denom) */ if (value<0.0) { - if (value==(int32)(value)) + if (value==(int32_t)(value)) { - *num=(int32)(value); + *num=(int32_t)(value); *denom=1; } else if (value>-1.0) { - *num=-(int32)((-value) * (double)0x7FFFFFFF); + *num=-(int32_t)((-value) * (double)0x7FFFFFFF); *denom=0x7FFFFFFF; } else { *num=-0x7FFFFFFF; - *denom=(int32)((double)0x7FFFFFFF / (-value)); + *denom=(int32_t)((double)0x7FFFFFFF / (-value)); } } else { - if (value==(int32)(value)) + if (value==(int32_t)(value)) { - *num=(int32)(value); + *num=(int32_t)(value); *denom=1; } else if (value<1.0) { - *num=(int32)((value) *(double)0x7FFFFFFF); + *num=(int32_t)((value) *(double)0x7FFFFFFF); *denom=0x7FFFFFFF; } else { *num=0x7FFFFFFF; - *denom=(int32)((double)0x7FFFFFFF / (value)); + *denom=(int32_t)((double)0x7FFFFFFF / (value)); } } } /*-- DoubleToSrational_direct() --------------*/ @@ -2710,16 +2710,16 @@ void DoubleToSrational_direct(double value, long *num, long *denom) * using the Euclidean algorithm to find the greatest common divisor (GCD) ------------------------------------------------------------------------*/ static -void ToRationalEuclideanGCD(double value, int blnUseSignedRange, int blnUseSmallRange, unsigned long long *ullNum, unsigned long long *ullDenom) +void ToRationalEuclideanGCD(double value, int blnUseSignedRange, int blnUseSmallRange, uint64_t *ullNum, uint64_t *ullDenom) { /* Internally, the integer variables can be bigger than the external ones, * as long as the result will fit into the external variable size. */ - unsigned long long val, numSum[3] = { 0, 1, 0 }, denomSum[3] = { 1, 0, 0 }; - unsigned long long aux, bigNum, bigDenom; - unsigned long long returnLimit; + uint64_t numSum[3] = { 0, 1, 0 }, denomSum[3] = { 1, 0, 0 }; + uint64_t aux, bigNum, bigDenom; + uint64_t returnLimit; int i; - unsigned long long nMax; + uint64_t nMax; double fMax; unsigned long maxDenom; /*-- nMax and fMax defines the initial accuracy of the starting fractional, @@ -2729,7 +2729,7 @@ void ToRationalEuclideanGCD(double value, int blnUseSignedRange, int blnUseSmall * For long long nMax = ((9223372036854775807-1)/2); for long nMax = ((2147483647-1)/2); */ if (blnUseSmallRange) { - nMax = (unsigned long long)((2147483647 - 1) / 2); /* for ULONG range */ + nMax = (uint64_t)((2147483647 - 1) / 2); /* for ULONG range */ } else { nMax = ((9223372036854775807 - 1) / 2); /* for ULLONG range */ @@ -2750,11 +2750,11 @@ void ToRationalEuclideanGCD(double value, int blnUseSignedRange, int blnUseSmall } /*-- First generate a rational fraction (bigNum/bigDenom) which represents the value - * as a rational number with the highest accuracy. Therefore, unsigned long long (uint64) is needed. + * as a rational number with the highest accuracy. Therefore, uint64_t (uint64_t) is needed. * This rational fraction is then reduced using the Euclidean algorithm to find the greatest common divisor (GCD). * bigNum = big numinator of value without fraction (or cut residual fraction) * bigDenom = big denominator of value - *-- Break-criteria so that uint64 cast to "bigNum" introduces no error and bigDenom has no overflow, + *-- Break-criteria so that uint64_t cast to "bigNum" introduces no error and bigDenom has no overflow, * and stop with enlargement of fraction when the double-value of it reaches an integer number without fractional part. */ bigDenom = 1; @@ -2762,19 +2762,17 @@ void ToRationalEuclideanGCD(double value, int blnUseSignedRange, int blnUseSmall bigDenom <<= 1; value *= 2; } - bigNum = (unsigned long long)value; + bigNum = (uint64_t)value; /*-- Start Euclidean algorithm to find the greatest common divisor (GCD) -- */ #define MAX_ITERATIONS 64 for (i = 0; i < MAX_ITERATIONS; i++) { + uint64_t val; /* if bigDenom is not zero, calculate integer part of fraction. */ if (bigDenom == 0) { - val = 0; break; } - else { - val = bigNum / bigDenom; - } + val = bigNum / bigDenom; /* Set bigDenom to reminder of bigNum/bigDenom and bigNum to previous denominator bigDenom. */ aux = bigNum; @@ -2819,11 +2817,11 @@ void ToRationalEuclideanGCD(double value, int blnUseSignedRange, int blnUseSmall * using the Euclidean algorithm to find the greatest common divisor (GCD) ------------------------------------------------------------------------*/ static -void DoubleToRational(double value, uint32 *num, uint32 *denom) +void DoubleToRational(double value, uint32_t *num, uint32_t *denom) { /*---- UN-SIGNED RATIONAL ---- */ double dblDiff, dblDiff2; - unsigned long long ullNum, ullDenom, ullNum2, ullDenom2; + uint64_t ullNum, ullDenom, ullNum2, ullDenom2; /*-- Check for negative values. If so it is an error. */ /* Test written that way to catch NaN */ @@ -2840,8 +2838,8 @@ void DoubleToRational(double value, uint32 *num, uint32 *denom) return; } /*-- Check for easy integer numbers -- */ - if (value == (uint32)(value)) { - *num = (uint32)value; + if (value == (uint32_t)(value)) { + *num = (uint32_t)value; *denom = 1; return; } @@ -2860,11 +2858,7 @@ void DoubleToRational(double value, uint32 *num, uint32 *denom) ToRationalEuclideanGCD(value, FALSE, TRUE, &ullNum2, &ullDenom2); /*-- Double-Check, that returned values fit into ULONG :*/ if (ullNum > 0xFFFFFFFFUL || ullDenom > 0xFFFFFFFFUL || ullNum2 > 0xFFFFFFFFUL || ullDenom2 > 0xFFFFFFFFUL) { -#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__)) - TIFFErrorExt(0, "TIFFLib: DoubleToRational()", " Num or Denom exceeds ULONG: val=%14.6f, num=%I64u, denom=%I64u | num2=%I64u, denom2=%I64u", value, ullNum, ullDenom, ullNum2, ullDenom2); -#else - TIFFErrorExt(0, "TIFFLib: DoubleToRational()", " Num or Denom exceeds ULONG: val=%14.6f, num=%12llu, denom=%12llu | num2=%12llu, denom2=%12llu", value, ullNum, ullDenom, ullNum2, ullDenom2); -#endif + TIFFErrorExt(0, "TIFFLib: DoubleToRational()", " Num or Denom exceeds ULONG: val=%14.6f, num=%12"PRIu64", denom=%12"PRIu64" | num2=%12"PRIu64", denom2=%12"PRIu64"", value, ullNum, ullDenom, ullNum2, ullDenom2); assert(0); } @@ -2872,12 +2866,12 @@ void DoubleToRational(double value, uint32 *num, uint32 *denom) dblDiff = fabs(value - ((double)ullNum / (double)ullDenom)); dblDiff2 = fabs(value - ((double)ullNum2 / (double)ullDenom2)); if (dblDiff < dblDiff2) { - *num = (uint32)ullNum; - *denom = (uint32)ullDenom; + *num = (uint32_t)ullNum; + *denom = (uint32_t)ullDenom; } else { - *num = (uint32)ullNum2; - *denom = (uint32)ullDenom2; + *num = (uint32_t)ullNum2; + *denom = (uint32_t)ullDenom2; } } /*-- DoubleToRational() -------------- */ @@ -2887,12 +2881,12 @@ void DoubleToRational(double value, uint32 *num, uint32 *denom) * using the Euclidean algorithm to find the greatest common divisor (GCD) ------------------------------------------------------------------------*/ static -void DoubleToSrational(double value, int32 *num, int32 *denom) +void DoubleToSrational(double value, int32_t *num, int32_t *denom) { /*---- SIGNED RATIONAL ----*/ int neg = 1; double dblDiff, dblDiff2; - unsigned long long ullNum, ullDenom, ullNum2, ullDenom2; + uint64_t ullNum, ullDenom, ullNum2, ullDenom2; /*-- Check for negative values and use then the positive one for internal calculations, but take the sign into account before returning. */ if (value < 0) { neg = -1; value = -value; } @@ -2904,8 +2898,8 @@ void DoubleToSrational(double value, int32 *num, int32 *denom) return; } /*-- Check for easy numbers -- */ - if (value == (int32)(value)) { - *num = (int32)(neg * value); + if (value == (int32_t)(value)) { + *num = (int32_t)(neg * value); *denom = 1; return; } @@ -2925,11 +2919,7 @@ void DoubleToSrational(double value, int32 *num, int32 *denom) ToRationalEuclideanGCD(value, TRUE, TRUE, &ullNum2, &ullDenom2); /*-- Double-Check, that returned values fit into LONG :*/ if (ullNum > 0x7FFFFFFFL || ullDenom > 0x7FFFFFFFL || ullNum2 > 0x7FFFFFFFL || ullDenom2 > 0x7FFFFFFFL) { -#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__)) - TIFFErrorExt(0, "TIFFLib: DoubleToSrational()", " Num or Denom exceeds LONG: val=%14.6f, num=%I64u, denom=%I64u | num2=%I64u, denom2=%I64u", neg*value, ullNum, ullDenom, ullNum2, ullDenom2); -#else - TIFFErrorExt(0, "TIFFLib: DoubleToSrational()", " Num or Denom exceeds LONG: val=%14.6f, num=%12llu, denom=%12llu | num2=%12llu, denom2=%12llu", neg*value, ullNum, ullDenom, ullNum2, ullDenom2); -#endif + TIFFErrorExt(0, "TIFFLib: DoubleToSrational()", " Num or Denom exceeds LONG: val=%14.6f, num=%12"PRIu64", denom=%12"PRIu64" | num2=%12"PRIu64", denom2=%12"PRIu64"", neg*value, ullNum, ullDenom, ullNum2, ullDenom2); assert(0); } @@ -2937,12 +2927,12 @@ void DoubleToSrational(double value, int32 *num, int32 *denom) dblDiff = fabs(value - ((double)ullNum / (double)ullDenom)); dblDiff2 = fabs(value - ((double)ullNum2 / (double)ullDenom2)); if (dblDiff < dblDiff2) { - *num = (int32)(neg * (long)ullNum); - *denom = (int32)ullDenom; + *num = (int32_t)(neg * (long)ullNum); + *denom = (int32_t)ullDenom; } else { - *num = (int32)(neg * (long)ullNum2); - *denom = (int32)ullDenom2; + *num = (int32_t)(neg * (long)ullNum2); + *denom = (int32_t)ullDenom2; } } /*-- DoubleToSrational() --------------*/ @@ -2952,7 +2942,7 @@ void DoubleToSrational(double value, int32 *num, int32 *denom) #ifdef notdef static int -TIFFWriteDirectoryTagCheckedFloat(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, float value) +TIFFWriteDirectoryTagCheckedFloat(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, float value) { float m; assert(sizeof(float)==4); @@ -2965,7 +2955,7 @@ TIFFWriteDirectoryTagCheckedFloat(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, ui #endif static int -TIFFWriteDirectoryTagCheckedFloatArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, float* value) +TIFFWriteDirectoryTagCheckedFloatArray(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, float* value) { assert(count<0x40000000); assert(sizeof(float)==4); @@ -2977,7 +2967,7 @@ TIFFWriteDirectoryTagCheckedFloatArray(TIFF* tif, uint32* ndir, TIFFDirEntry* di #ifdef notdef static int -TIFFWriteDirectoryTagCheckedDouble(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, double value) +TIFFWriteDirectoryTagCheckedDouble(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, double value) { double m; assert(sizeof(double)==8); @@ -2990,7 +2980,7 @@ TIFFWriteDirectoryTagCheckedDouble(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, u #endif static int -TIFFWriteDirectoryTagCheckedDoubleArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, double* value) +TIFFWriteDirectoryTagCheckedDoubleArray(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, double* value) { assert(count<0x20000000); assert(sizeof(double)==8); @@ -3001,20 +2991,20 @@ TIFFWriteDirectoryTagCheckedDoubleArray(TIFF* tif, uint32* ndir, TIFFDirEntry* d } static int -TIFFWriteDirectoryTagCheckedIfdArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, uint32* value) +TIFFWriteDirectoryTagCheckedIfdArray(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, uint32_t* value) { assert(count<0x40000000); - assert(sizeof(uint32)==4); + assert(sizeof(uint32_t) == 4); if (tif->tif_flags&TIFF_SWAB) TIFFSwabArrayOfLong(value,count); return(TIFFWriteDirectoryTagData(tif,ndir,dir,tag,TIFF_IFD,count,count*4,value)); } static int -TIFFWriteDirectoryTagCheckedIfd8Array(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, uint64* value) +TIFFWriteDirectoryTagCheckedIfd8Array(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint32_t count, uint64_t* value) { assert(count<0x20000000); - assert(sizeof(uint64)==8); + assert(sizeof(uint64_t) == 8); assert(tif->tif_flags&TIFF_BIGTIFF); if (tif->tif_flags&TIFF_SWAB) TIFFSwabArrayOfLong8(value,count); @@ -3022,10 +3012,10 @@ TIFFWriteDirectoryTagCheckedIfd8Array(TIFF* tif, uint32* ndir, TIFFDirEntry* dir } static int -TIFFWriteDirectoryTagData(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint16 datatype, uint32 count, uint32 datalength, void* data) +TIFFWriteDirectoryTagData(TIFF* tif, uint32_t* ndir, TIFFDirEntry* dir, uint16_t tag, uint16_t datatype, uint32_t count, uint32_t datalength, void* data) { static const char module[] = "TIFFWriteDirectoryTagData"; - uint32 m; + uint32_t m; m=0; while (m<(*ndir)) { @@ -3036,7 +3026,7 @@ TIFFWriteDirectoryTagData(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag } if (m<(*ndir)) { - uint32 n; + uint32_t n; for (n=*ndir; n>m; n--) dir[n]=dir[n-1]; } @@ -3053,11 +3043,11 @@ TIFFWriteDirectoryTagData(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag } else { - uint64 na,nb; + uint64_t na,nb; na=tif->tif_dataoff; nb=na+datalength; if (!(tif->tif_flags&TIFF_BIGTIFF)) - nb=(uint32)nb; + nb=(uint32_t)nb; if ((nb<na)||(nb<datalength)) { TIFFErrorExt(tif->tif_clientdata,module,"Maximum TIFF file size exceeded"); @@ -3079,8 +3069,8 @@ TIFFWriteDirectoryTagData(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag tif->tif_dataoff++; if (!(tif->tif_flags&TIFF_BIGTIFF)) { - uint32 o; - o=(uint32)na; + uint32_t o; + o=(uint32_t)na; if (tif->tif_flags&TIFF_SWAB) TIFFSwabLong(&o); _TIFFmemcpy(&dir[m].tdir_offset,&o,4); @@ -3113,8 +3103,8 @@ TIFFLinkDirectory(TIFF* tif) { if (!(tif->tif_flags&TIFF_BIGTIFF)) { - uint32 m; - m = (uint32)tif->tif_diroff; + uint32_t m; + m = (uint32_t)tif->tif_diroff; if (tif->tif_flags & TIFF_SWAB) TIFFSwabLong(&m); (void) TIFFSeekFile(tif, tif->tif_subifdoff, SEEK_SET); @@ -3136,7 +3126,7 @@ TIFFLinkDirectory(TIFF* tif) } else { - uint64 m; + uint64_t m; m = tif->tif_diroff; if (tif->tif_flags & TIFF_SWAB) TIFFSwabLong8(&m); @@ -3161,16 +3151,16 @@ TIFFLinkDirectory(TIFF* tif) if (!(tif->tif_flags&TIFF_BIGTIFF)) { - uint32 m; - uint32 nextdir; - m = (uint32)(tif->tif_diroff); + uint32_t m; + uint32_t nextdir; + m = (uint32_t)(tif->tif_diroff); if (tif->tif_flags & TIFF_SWAB) TIFFSwabLong(&m); if (tif->tif_header.classic.tiff_diroff == 0) { /* * First directory, overwrite offset in header. */ - tif->tif_header.classic.tiff_diroff = (uint32) tif->tif_diroff; + tif->tif_header.classic.tiff_diroff = (uint32_t) tif->tif_diroff; (void) TIFFSeekFile(tif,4, SEEK_SET); if (!WriteOK(tif, &m, 4)) { TIFFErrorExt(tif->tif_clientdata, tif->tif_name, @@ -3184,8 +3174,8 @@ TIFFLinkDirectory(TIFF* tif) */ nextdir = tif->tif_header.classic.tiff_diroff; while(1) { - uint16 dircount; - uint32 nextnextdir; + uint16_t dircount; + uint32_t nextnextdir; if (!SeekOK(tif, nextdir) || !ReadOK(tif, &dircount, 2)) { @@ -3220,8 +3210,8 @@ TIFFLinkDirectory(TIFF* tif) } else { - uint64 m; - uint64 nextdir; + uint64_t m; + uint64_t nextdir; m = tif->tif_diroff; if (tif->tif_flags & TIFF_SWAB) TIFFSwabLong8(&m); @@ -3243,9 +3233,9 @@ TIFFLinkDirectory(TIFF* tif) */ nextdir = tif->tif_header.big.tiff_diroff; while(1) { - uint64 dircount64; - uint16 dircount; - uint64 nextnextdir; + uint64_t dircount64; + uint16_t dircount; + uint64_t nextnextdir; if (!SeekOK(tif, nextdir) || !ReadOK(tif, &dircount64, 8)) { @@ -3261,7 +3251,7 @@ TIFFLinkDirectory(TIFF* tif) "Sanity check on tag count failed, likely corrupt TIFF"); return (0); } - dircount=(uint16)dircount64; + dircount=(uint16_t)dircount64; (void) TIFFSeekFile(tif, nextdir+8+dircount*20, SEEK_SET); if (!ReadOK(tif, &nextnextdir, 8)) { @@ -3302,21 +3292,21 @@ TIFFLinkDirectory(TIFF* tif) /************************************************************************/ int -_TIFFRewriteField(TIFF* tif, uint16 tag, TIFFDataType in_datatype, +_TIFFRewriteField(TIFF* tif, uint16_t tag, TIFFDataType in_datatype, tmsize_t count, void* data) { static const char module[] = "TIFFResetField"; /* const TIFFField* fip = NULL; */ - uint16 dircount; + uint16_t dircount; tmsize_t dirsize; - uint8 direntry_raw[20]; - uint16 entry_tag = 0; - uint16 entry_type = 0; - uint64 entry_count = 0; - uint64 entry_offset = 0; + uint8_t direntry_raw[20]; + uint16_t entry_tag = 0; + uint16_t entry_type = 0; + uint64_t entry_count = 0; + uint64_t entry_offset = 0; int value_in_entry = 0; - uint64 read_offset; - uint8 *buf_to_write = NULL; + uint64_t read_offset; + uint8_t *buf_to_write = NULL; TIFFDataType datatype; /* -------------------------------------------------------------------- */ @@ -3355,7 +3345,7 @@ _TIFFRewriteField(TIFF* tif, uint16 tag, TIFFDataType in_datatype, if (!(tif->tif_flags&TIFF_BIGTIFF)) { - if (!ReadOK(tif, &dircount, sizeof (uint16))) { + if (!ReadOK(tif, &dircount, sizeof (uint16_t))) { TIFFErrorExt(tif->tif_clientdata, module, "%s: Can not read TIFF directory count", tif->tif_name); @@ -3366,8 +3356,8 @@ _TIFFRewriteField(TIFF* tif, uint16 tag, TIFFDataType in_datatype, dirsize = 12; read_offset += 2; } else { - uint64 dircount64; - if (!ReadOK(tif, &dircount64, sizeof (uint64))) { + uint64_t dircount64; + if (!ReadOK(tif, &dircount64, sizeof (uint64_t))) { TIFFErrorExt(tif->tif_clientdata, module, "%s: Can not read TIFF directory count", tif->tif_name); @@ -3375,7 +3365,7 @@ _TIFFRewriteField(TIFF* tif, uint16 tag, TIFFDataType in_datatype, } if (tif->tif_flags & TIFF_SWAB) TIFFSwabLong8(&dircount64); - dircount = (uint16)dircount64; + dircount = (uint16_t)dircount64; dirsize = 20; read_offset += 8; } @@ -3392,7 +3382,7 @@ _TIFFRewriteField(TIFF* tif, uint16 tag, TIFFDataType in_datatype, return 0; } - memcpy( &entry_tag, direntry_raw + 0, sizeof(uint16) ); + memcpy( &entry_tag, direntry_raw + 0, sizeof(uint16_t) ); if (tif->tif_flags&TIFF_SWAB) TIFFSwabShort( &entry_tag ); @@ -3405,7 +3395,7 @@ _TIFFRewriteField(TIFF* tif, uint16 tag, TIFFDataType in_datatype, if( entry_tag != tag ) { TIFFErrorExt(tif->tif_clientdata, module, - "%s: Could not find tag %d.", + "%s: Could not find tag %"PRIu16".", tif->tif_name, tag ); return 0; } @@ -3413,31 +3403,31 @@ _TIFFRewriteField(TIFF* tif, uint16 tag, TIFFDataType in_datatype, /* -------------------------------------------------------------------- */ /* Extract the type, count and offset for this entry. */ /* -------------------------------------------------------------------- */ - memcpy( &entry_type, direntry_raw + 2, sizeof(uint16) ); + memcpy( &entry_type, direntry_raw + 2, sizeof(uint16_t) ); if (tif->tif_flags&TIFF_SWAB) TIFFSwabShort( &entry_type ); if (!(tif->tif_flags&TIFF_BIGTIFF)) { - uint32 value; + uint32_t value; - memcpy( &value, direntry_raw + 4, sizeof(uint32) ); + memcpy( &value, direntry_raw + 4, sizeof(uint32_t) ); if (tif->tif_flags&TIFF_SWAB) TIFFSwabLong( &value ); entry_count = value; - memcpy( &value, direntry_raw + 8, sizeof(uint32) ); + memcpy( &value, direntry_raw + 8, sizeof(uint32_t) ); if (tif->tif_flags&TIFF_SWAB) TIFFSwabLong( &value ); entry_offset = value; } else { - memcpy( &entry_count, direntry_raw + 4, sizeof(uint64) ); + memcpy( &entry_count, direntry_raw + 4, sizeof(uint64_t) ); if (tif->tif_flags&TIFF_SWAB) TIFFSwabLong8( &entry_count ); - memcpy( &entry_offset, direntry_raw + 12, sizeof(uint64) ); + memcpy( &entry_offset, direntry_raw + 12, sizeof(uint64_t) ); if (tif->tif_flags&TIFF_SWAB) TIFFSwabLong8( &entry_offset ); } @@ -3524,8 +3514,8 @@ _TIFFRewriteField(TIFF* tif, uint16 tag, TIFFDataType in_datatype, /* swabbing as needed. */ /* -------------------------------------------------------------------- */ buf_to_write = - (uint8 *)_TIFFCheckMalloc(tif, count, TIFFDataWidth(datatype), - "for field buffer."); + (uint8_t *)_TIFFCheckMalloc(tif, count, TIFFDataWidth(datatype), + "for field buffer."); if (!buf_to_write) return 0; @@ -3537,9 +3527,9 @@ _TIFFRewriteField(TIFF* tif, uint16 tag, TIFFDataType in_datatype, for( i = 0; i < count; i++ ) { - ((int32 *) buf_to_write)[i] = - (int32) ((int64 *) data)[i]; - if( (int64) ((int32 *) buf_to_write)[i] != ((int64 *) data)[i] ) + ((int32_t *) buf_to_write)[i] = + (int32_t) ((int64_t *) data)[i]; + if((int64_t) ((int32_t *) buf_to_write)[i] != ((int64_t *) data)[i] ) { _TIFFfree( buf_to_write ); TIFFErrorExt( tif->tif_clientdata, module, @@ -3555,9 +3545,9 @@ _TIFFRewriteField(TIFF* tif, uint16 tag, TIFFDataType in_datatype, for( i = 0; i < count; i++ ) { - ((uint32 *) buf_to_write)[i] = - (uint32) ((uint64 *) data)[i]; - if( (uint64) ((uint32 *) buf_to_write)[i] != ((uint64 *) data)[i] ) + ((uint32_t *) buf_to_write)[i] = + (uint32_t) ((uint64_t *) data)[i]; + if((uint64_t) ((uint32_t *) buf_to_write)[i] != ((uint64_t *) data)[i] ) { _TIFFfree( buf_to_write ); TIFFErrorExt( tif->tif_clientdata, module, @@ -3572,9 +3562,9 @@ _TIFFRewriteField(TIFF* tif, uint16 tag, TIFFDataType in_datatype, for( i = 0; i < count; i++ ) { - ((uint16 *) buf_to_write)[i] = - (uint16) ((uint64 *) data)[i]; - if( (uint64) ((uint16 *) buf_to_write)[i] != ((uint64 *) data)[i] ) + ((uint16_t *) buf_to_write)[i] = + (uint16_t) ((uint64_t *) data)[i]; + if((uint64_t) ((uint16_t *) buf_to_write)[i] != ((uint64_t *) data)[i] ) { _TIFFfree( buf_to_write ); TIFFErrorExt( tif->tif_clientdata, module, @@ -3593,11 +3583,11 @@ _TIFFRewriteField(TIFF* tif, uint16 tag, TIFFDataType in_datatype, if( TIFFDataWidth(datatype) > 1 && (tif->tif_flags&TIFF_SWAB) ) { if( TIFFDataWidth(datatype) == 2 ) - TIFFSwabArrayOfShort( (uint16 *) buf_to_write, count ); + TIFFSwabArrayOfShort((uint16_t *) buf_to_write, count ); else if( TIFFDataWidth(datatype) == 4 ) - TIFFSwabArrayOfLong( (uint32 *) buf_to_write, count ); + TIFFSwabArrayOfLong((uint32_t *) buf_to_write, count ); else if( TIFFDataWidth(datatype) == 8 ) - TIFFSwabArrayOfLong8( (uint64 *) buf_to_write, count ); + TIFFSwabArrayOfLong8((uint64_t *) buf_to_write, count ); } /* -------------------------------------------------------------------- */ @@ -3642,7 +3632,7 @@ _TIFFRewriteField(TIFF* tif, uint16 tag, TIFFDataType in_datatype, /* over the old values without altering the directory entry at */ /* all. */ /* -------------------------------------------------------------------- */ - if( entry_count == (uint64)count && entry_type == (uint16) datatype ) + if( entry_count == (uint64_t)count && entry_type == (uint16_t) datatype ) { if (!SeekOK(tif, entry_offset)) { _TIFFfree( buf_to_write ); @@ -3688,34 +3678,34 @@ _TIFFRewriteField(TIFF* tif, uint16 tag, TIFFDataType in_datatype, /* Adjust the directory entry. */ /* -------------------------------------------------------------------- */ entry_type = datatype; - entry_count = (uint64)count; - memcpy( direntry_raw + 2, &entry_type, sizeof(uint16) ); + entry_count = (uint64_t)count; + memcpy( direntry_raw + 2, &entry_type, sizeof(uint16_t) ); if (tif->tif_flags&TIFF_SWAB) - TIFFSwabShort( (uint16 *) (direntry_raw + 2) ); + TIFFSwabShort( (uint16_t *) (direntry_raw + 2) ); if (!(tif->tif_flags&TIFF_BIGTIFF)) { - uint32 value; + uint32_t value; - value = (uint32) entry_count; - memcpy( direntry_raw + 4, &value, sizeof(uint32) ); + value = (uint32_t) entry_count; + memcpy( direntry_raw + 4, &value, sizeof(uint32_t) ); if (tif->tif_flags&TIFF_SWAB) - TIFFSwabLong( (uint32 *) (direntry_raw + 4) ); + TIFFSwabLong( (uint32_t *) (direntry_raw + 4) ); - value = (uint32) entry_offset; - memcpy( direntry_raw + 8, &value, sizeof(uint32) ); + value = (uint32_t) entry_offset; + memcpy( direntry_raw + 8, &value, sizeof(uint32_t) ); if (tif->tif_flags&TIFF_SWAB) - TIFFSwabLong( (uint32 *) (direntry_raw + 8) ); + TIFFSwabLong( (uint32_t *) (direntry_raw + 8) ); } else { - memcpy( direntry_raw + 4, &entry_count, sizeof(uint64) ); + memcpy( direntry_raw + 4, &entry_count, sizeof(uint64_t) ); if (tif->tif_flags&TIFF_SWAB) - TIFFSwabLong8( (uint64 *) (direntry_raw + 4) ); + TIFFSwabLong8( (uint64_t *) (direntry_raw + 4) ); - memcpy( direntry_raw + 12, &entry_offset, sizeof(uint64) ); + memcpy( direntry_raw + 12, &entry_offset, sizeof(uint64_t) ); if (tif->tif_flags&TIFF_SWAB) - TIFFSwabLong8( (uint64 *) (direntry_raw + 12) ); + TIFFSwabLong8( (uint64_t *) (direntry_raw + 12) ); } /* -------------------------------------------------------------------- */ diff --git a/tiff/libtiff/tif_dumpmode.c b/tiff/libtiff/tif_dumpmode.c index 4a0b07f5..f1d3c4ad 100644 --- a/tiff/libtiff/tif_dumpmode.c +++ b/tiff/libtiff/tif_dumpmode.c @@ -40,7 +40,7 @@ DumpFixupTags(TIFF* tif) * Encode a hunk of pixels. */ static int -DumpModeEncode(TIFF* tif, uint8* pp, tmsize_t cc, uint16 s) +DumpModeEncode(TIFF* tif, uint8_t* pp, tmsize_t cc, uint16_t s) { (void) s; while (cc > 0) { @@ -73,24 +73,16 @@ DumpModeEncode(TIFF* tif, uint8* pp, tmsize_t cc, uint16 s) * Decode a hunk of pixels. */ static int -DumpModeDecode(TIFF* tif, uint8* buf, tmsize_t cc, uint16 s) +DumpModeDecode(TIFF* tif, uint8_t* buf, tmsize_t cc, uint16_t s) { static const char module[] = "DumpModeDecode"; (void) s; if (tif->tif_rawcc < cc) { -#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__)) TIFFErrorExt(tif->tif_clientdata, module, -"Not enough data for scanline %lu, expected a request for at most %I64d bytes, got a request for %I64d bytes", - (unsigned long) tif->tif_row, - (signed __int64) tif->tif_rawcc, - (signed __int64) cc); -#else - TIFFErrorExt(tif->tif_clientdata, module, -"Not enough data for scanline %lu, expected a request for at most %lld bytes, got a request for %lld bytes", - (unsigned long) tif->tif_row, - (signed long long) tif->tif_rawcc, - (signed long long) cc); -#endif +"Not enough data for scanline %"PRIu32", expected a request for at most %"TIFF_SSIZE_FORMAT" bytes, got a request for %"TIFF_SSIZE_FORMAT" bytes", + tif->tif_row, + tif->tif_rawcc, + cc); return (0); } /* @@ -108,7 +100,7 @@ DumpModeDecode(TIFF* tif, uint8* buf, tmsize_t cc, uint16 s) * Seek forwards nrows in the current strip. */ static int -DumpModeSeek(TIFF* tif, uint32 nrows) +DumpModeSeek(TIFF* tif, uint32_t nrows) { tif->tif_rawcp += nrows * tif->tif_scanlinesize; tif->tif_rawcc -= nrows * tif->tif_scanlinesize; diff --git a/tiff/libtiff/tif_extension.c b/tiff/libtiff/tif_extension.c index 87d3cfcb..9d46d3ea 100644 --- a/tiff/libtiff/tif_extension.c +++ b/tiff/libtiff/tif_extension.c @@ -39,13 +39,13 @@ int TIFFGetTagListCount( TIFF *tif ) return td->td_customValueCount; } -uint32 TIFFGetTagListEntry( TIFF *tif, int tag_index ) +uint32_t TIFFGetTagListEntry(TIFF *tif, int tag_index ) { TIFFDirectory* td = &tif->tif_dir; if( tag_index < 0 || tag_index >= td->td_customValueCount ) - return (uint32)(-1); + return (uint32_t)(-1); else return td->td_customValues[tag_index].info->field_tag; } diff --git a/tiff/libtiff/tif_fax3.c b/tiff/libtiff/tif_fax3.c index 9ab5b26a..f68e83a2 100644 --- a/tiff/libtiff/tif_fax3.c +++ b/tiff/libtiff/tif_fax3.c @@ -49,12 +49,12 @@ typedef struct { int rw_mode; /* O_RDONLY for decode, else encode */ int mode; /* operating mode */ tmsize_t rowbytes; /* bytes in a decoded scanline */ - uint32 rowpixels; /* pixels in a scanline */ + uint32_t rowpixels; /* pixels in a scanline */ - uint16 cleanfaxdata; /* CleanFaxData tag */ - uint32 badfaxrun; /* BadFaxRun tag */ - uint32 badfaxlines; /* BadFaxLines tag */ - uint32 groupoptions; /* Group 3/4 options tag */ + uint16_t cleanfaxdata; /* CleanFaxData tag */ + uint32_t badfaxrun; /* BadFaxRun tag */ + uint32_t badfaxlines; /* BadFaxLines tag */ + uint32_t groupoptions; /* Group 3/4 options tag */ TIFFVGetMethod vgetparent; /* super-class method */ TIFFVSetMethod vsetparent; /* super-class method */ @@ -68,14 +68,14 @@ typedef struct { /* Decoder state info */ const unsigned char* bitmap; /* bit reversal table */ - uint32 data; /* current i/o byte/word */ + uint32_t data; /* current i/o byte/word */ int bit; /* current i/o bit in byte */ int EOLcnt; /* count of EOL codes recognized */ TIFFFaxFillFunc fill; /* fill routine */ - uint32* runs; /* b&w runs for current/previous row */ - uint32 nruns; /* size of the refruns / curruns arrays */ - uint32* refruns; /* runs for reference line */ - uint32* curruns; /* runs for current line */ + uint32_t* runs; /* b&w runs for current/previous row */ + uint32_t nruns; /* size of the refruns / curruns arrays */ + uint32_t* refruns; /* runs for reference line */ + uint32_t* curruns; /* runs for current line */ /* Encoder state info */ Ttag tag; /* encoding state */ @@ -104,20 +104,20 @@ typedef struct { Fax3CodecState* sp = DecoderState(tif); \ int a0; /* reference element */ \ int lastx = sp->b.rowpixels; /* last element in row */ \ - uint32 BitAcc; /* bit accumulator */ \ + uint32_t BitAcc; /* bit accumulator */ \ int BitsAvail; /* # valid bits in BitAcc */ \ int RunLength; /* length of current run */ \ unsigned char* cp; /* next byte of input data */ \ unsigned char* ep; /* end of input data */ \ - uint32* pa; /* place to stuff next run */ \ - uint32* thisrun; /* current row's run array */ \ + uint32_t* pa; /* place to stuff next run */ \ + uint32_t* thisrun; /* current row's run array */ \ int EOLcnt; /* # EOL codes recognized */ \ const unsigned char* bitmap = sp->bitmap; /* input data bit reverser */ \ const TIFFFaxTabEnt* TabEnt #define DECLARE_STATE_2D(tif, sp, mod) \ DECLARE_STATE(tif, sp, mod); \ int b1; /* next change on prev line */ \ - uint32* pb /* next run in reference line */\ + uint32_t* pb /* next run in reference line */\ /* * Load any state that may be changed during decoding. */ @@ -135,15 +135,15 @@ typedef struct { sp->bit = BitsAvail; \ sp->data = BitAcc; \ sp->EOLcnt = EOLcnt; \ - tif->tif_rawcc -= (tmsize_t)((uint8*) cp - tif->tif_rawcp); \ - tif->tif_rawcp = (uint8*) cp; \ + tif->tif_rawcc -= (tmsize_t)((uint8_t*) cp - tif->tif_rawcp); \ + tif->tif_rawcp = (uint8_t*) cp; \ } while (0) /* * Setup state for decoding a strip. */ static int -Fax3PreDecode(TIFF* tif, uint16 s) +Fax3PreDecode(TIFF* tif, uint16_t s) { Fax3CodecState* sp = DecoderState(tif); @@ -164,7 +164,7 @@ Fax3PreDecode(TIFF* tif, uint16 s) sp->curruns = sp->runs; if (sp->refruns) { /* init reference line to white */ sp->refruns = sp->runs + sp->nruns; - sp->refruns[0] = (uint32) sp->b.rowpixels; + sp->refruns[0] = (uint32_t) sp->b.rowpixels; sp->refruns[1] = 0; } sp->line = 0; @@ -178,9 +178,9 @@ Fax3PreDecode(TIFF* tif, uint16 s) */ static void -Fax3Unexpected(const char* module, TIFF* tif, uint32 line, uint32 a0) +Fax3Unexpected(const char* module, TIFF* tif, uint32_t line, uint32_t a0) { - TIFFErrorExt(tif->tif_clientdata, module, "Bad code word at line %u of %s %u (x %u)", + TIFFErrorExt(tif->tif_clientdata, module, "Bad code word at line %"PRIu32" of %s %"PRIu32" (x %"PRIu32")", line, isTiled(tif) ? "tile" : "strip", (isTiled(tif) ? tif->tif_curtile : tif->tif_curstrip), a0); @@ -188,10 +188,10 @@ Fax3Unexpected(const char* module, TIFF* tif, uint32 line, uint32 a0) #define unexpected(table, a0) Fax3Unexpected(module, tif, sp->line, a0) static void -Fax3Extension(const char* module, TIFF* tif, uint32 line, uint32 a0) +Fax3Extension(const char* module, TIFF* tif, uint32_t line, uint32_t a0) { TIFFErrorExt(tif->tif_clientdata, module, - "Uncompressed data (not supported) at line %u of %s %u (x %u)", + "Uncompressed data (not supported) at line %"PRIu32" of %s %"PRIu32" (x %"PRIu32")", line, isTiled(tif) ? "tile" : "strip", (isTiled(tif) ? tif->tif_curtile : tif->tif_curstrip), a0); @@ -199,9 +199,9 @@ Fax3Extension(const char* module, TIFF* tif, uint32 line, uint32 a0) #define extension(a0) Fax3Extension(module, tif, sp->line, a0) static void -Fax3BadLength(const char* module, TIFF* tif, uint32 line, uint32 a0, uint32 lastx) +Fax3BadLength(const char* module, TIFF* tif, uint32_t line, uint32_t a0, uint32_t lastx) { - TIFFWarningExt(tif->tif_clientdata, module, "%s at line %u of %s %u (got %u, expected %u)", + TIFFWarningExt(tif->tif_clientdata, module, "%s at line %"PRIu32" of %s %"PRIu32" (got %"PRIu32", expected %"PRIu32")", a0 < lastx ? "Premature EOL" : "Line length mismatch", line, isTiled(tif) ? "tile" : "strip", (isTiled(tif) ? tif->tif_curtile : tif->tif_curstrip), @@ -210,9 +210,9 @@ Fax3BadLength(const char* module, TIFF* tif, uint32 line, uint32 a0, uint32 last #define badlength(a0,lastx) Fax3BadLength(module, tif, sp->line, a0, lastx) static void -Fax3PrematureEOF(const char* module, TIFF* tif, uint32 line, uint32 a0) +Fax3PrematureEOF(const char* module, TIFF* tif, uint32_t line, uint32_t a0) { - TIFFWarningExt(tif->tif_clientdata, module, "Premature EOF at line %u of %s %u (x %u)", + TIFFWarningExt(tif->tif_clientdata, module, "Premature EOF at line %"PRIu32" of %s %"PRIu32" (x %"PRIu32")", line, isTiled(tif) ? "tile" : "strip", (isTiled(tif) ? tif->tif_curtile : tif->tif_curstrip), a0); @@ -229,7 +229,7 @@ Fax3PrematureEOF(const char* module, TIFF* tif, uint32 line, uint32 a0) * @returns 1 for success, -1 in case of error */ static int -Fax3Decode1D(TIFF* tif, uint8* buf, tmsize_t occ, uint16 s) +Fax3Decode1D(TIFF* tif, uint8_t* buf, tmsize_t occ, uint16_t s) { DECLARE_STATE(tif, sp, "Fax3Decode1D"); (void) s; @@ -245,8 +245,8 @@ Fax3Decode1D(TIFF* tif, uint8* buf, tmsize_t occ, uint16 s) RunLength = 0; pa = thisrun; #ifdef FAX3_DEBUG - printf("\nBitAcc=%08X, BitsAvail = %d\n", BitAcc, BitsAvail); - printf("-------------------- %d\n", tif->tif_row); + printf("\nBitAcc=%08"PRIX32", BitsAvail = %d\n", BitAcc, BitsAvail); + printf("-------------------- %"PRIu32"\n", tif->tif_row); fflush(stdout); #endif SYNC_EOL(EOF1D); @@ -272,7 +272,7 @@ Fax3Decode1D(TIFF* tif, uint8* buf, tmsize_t occ, uint16 s) * Decode the requested amount of G3 2D-encoded data. */ static int -Fax3Decode2D(TIFF* tif, uint8* buf, tmsize_t occ, uint16 s) +Fax3Decode2D(TIFF* tif, uint8_t* buf, tmsize_t occ, uint16_t s) { DECLARE_STATE_2D(tif, sp, "Fax3Decode2D"); int is1D; /* current line is 1d/2d-encoded */ @@ -288,7 +288,7 @@ Fax3Decode2D(TIFF* tif, uint8* buf, tmsize_t occ, uint16 s) RunLength = 0; pa = thisrun = sp->curruns; #ifdef FAX3_DEBUG - printf("\nBitAcc=%08X, BitsAvail = %d EOLcnt = %d", + printf("\nBitAcc=%08"PRIX32", BitsAvail = %d EOLcnt = %d", BitAcc, BitsAvail, EOLcnt); #endif SYNC_EOL(EOF2D); @@ -296,7 +296,7 @@ Fax3Decode2D(TIFF* tif, uint8* buf, tmsize_t occ, uint16 s) is1D = GetBits(1); /* 1D/2D-encoding tag bit */ ClrBits(1); #ifdef FAX3_DEBUG - printf(" %s\n-------------------- %d\n", + printf(" %s\n-------------------- %"PRIu32"\n", is1D ? "1D" : "2D", tif->tif_row); fflush(stdout); #endif @@ -310,7 +310,7 @@ Fax3Decode2D(TIFF* tif, uint8* buf, tmsize_t occ, uint16 s) if (pa < thisrun + sp->nruns) { SETVALUE(0); /* imaginary change for reference */ } - SWAP(uint32*, sp->curruns, sp->refruns); + SWAP(uint32_t*, sp->curruns, sp->refruns); buf += sp->b.rowbytes; occ -= sp->b.rowbytes; sp->line++; @@ -327,89 +327,38 @@ Fax3Decode2D(TIFF* tif, uint8* buf, tmsize_t occ, uint16 s) } #undef SWAP -/* - * The ZERO & FILL macros must handle spans < 2*sizeof(long) bytes. - * For machines with 64-bit longs this is <16 bytes; otherwise - * this is <8 bytes. We optimize the code here to reflect the - * machine characteristics. - */ -#if SIZEOF_UNSIGNED_LONG == 8 -# define FILL(n, cp) \ - switch (n) { \ - case 15:(cp)[14] = 0xff; /*-fallthrough*/ \ - case 14:(cp)[13] = 0xff; /*-fallthrough*/ \ - case 13:(cp)[12] = 0xff; /*-fallthrough*/ \ - case 12:(cp)[11] = 0xff; /*-fallthrough*/ \ - case 11:(cp)[10] = 0xff; /*-fallthrough*/ \ - case 10: (cp)[9] = 0xff; /*-fallthrough*/ \ - case 9: (cp)[8] = 0xff; /*-fallthrough*/ \ - case 8: (cp)[7] = 0xff; /*-fallthrough*/ \ - case 7: (cp)[6] = 0xff; /*-fallthrough*/ \ - case 6: (cp)[5] = 0xff; /*-fallthrough*/ \ - case 5: (cp)[4] = 0xff; /*-fallthrough*/ \ - case 4: (cp)[3] = 0xff; /*-fallthrough*/ \ - case 3: (cp)[2] = 0xff; /*-fallthrough*/ \ - case 2: (cp)[1] = 0xff; /*-fallthrough*/ \ - case 1: (cp)[0] = 0xff; (cp) += (n); /*-fallthrough*/ \ - case 0: ; \ - } -# define ZERO(n, cp) \ - switch (n) { \ - case 15:(cp)[14] = 0; /*-fallthrough*/ \ - case 14:(cp)[13] = 0; /*-fallthrough*/ \ - case 13:(cp)[12] = 0; /*-fallthrough*/ \ - case 12:(cp)[11] = 0; /*-fallthrough*/ \ - case 11:(cp)[10] = 0; /*-fallthrough*/ \ - case 10: (cp)[9] = 0; /*-fallthrough*/ \ - case 9: (cp)[8] = 0; /*-fallthrough*/ \ - case 8: (cp)[7] = 0; /*-fallthrough*/ \ - case 7: (cp)[6] = 0; /*-fallthrough*/ \ - case 6: (cp)[5] = 0; /*-fallthrough*/ \ - case 5: (cp)[4] = 0; /*-fallthrough*/ \ - case 4: (cp)[3] = 0; /*-fallthrough*/ \ - case 3: (cp)[2] = 0; /*-fallthrough*/ \ - case 2: (cp)[1] = 0; /*-fallthrough*/ \ - case 1: (cp)[0] = 0; (cp) += (n); /*-fallthrough*/ \ - case 0: ; \ +# define FILL(n, cp) \ + { \ + int32_t ifill;\ + for (ifill = 0; ifill < (n); ++ifill) \ + { \ + (cp)[ifill] = 0xff; \ + } \ + (cp) += (n);\ } -#else -# define FILL(n, cp) \ - switch (n) { \ - case 7: (cp)[6] = 0xff; /*-fallthrough*/ \ - case 6: (cp)[5] = 0xff; /*-fallthrough*/ \ - case 5: (cp)[4] = 0xff; /*-fallthrough*/ \ - case 4: (cp)[3] = 0xff; /*-fallthrough*/ \ - case 3: (cp)[2] = 0xff; /*-fallthrough*/ \ - case 2: (cp)[1] = 0xff; /*-fallthrough*/ \ - case 1: (cp)[0] = 0xff; (cp) += (n); /*-fallthrough*/ \ - case 0: ; \ - } -# define ZERO(n, cp) \ - switch (n) { \ - case 7: (cp)[6] = 0; /*-fallthrough*/ \ - case 6: (cp)[5] = 0; /*-fallthrough*/ \ - case 5: (cp)[4] = 0; /*-fallthrough*/ \ - case 4: (cp)[3] = 0; /*-fallthrough*/ \ - case 3: (cp)[2] = 0; /*-fallthrough*/ \ - case 2: (cp)[1] = 0; /*-fallthrough*/ \ - case 1: (cp)[0] = 0; (cp) += (n); /*-fallthrough*/ \ - case 0: ; \ - } -#endif +# define ZERO(n, cp) \ + {\ + int32_t izero; \ + for (izero = 0; izero < (n); ++izero) \ + { \ + (cp)[izero] = 0; \ + } \ + (cp) += (n);\ + } /* * Bit-fill a row according to the white/black * runs generated during G3/G4 decoding. */ void -_TIFFFax3fillruns(unsigned char* buf, uint32* runs, uint32* erun, uint32 lastx) +_TIFFFax3fillruns(unsigned char* buf, uint32_t* runs, uint32_t* erun, uint32_t lastx) { static const unsigned char _fillmasks[] = { 0x00, 0x80, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc, 0xfe, 0xff }; unsigned char* cp; - uint32 x, bx, run; - int32 n, nw; - long* lp; + uint32_t x, bx, run; + int32_t n, nw; + int64_t* lp; if ((erun-runs)&1) *erun++ = 0; @@ -417,7 +366,7 @@ _TIFFFax3fillruns(unsigned char* buf, uint32* runs, uint32* erun, uint32 lastx) for (; runs < erun; runs += 2) { run = runs[0]; if (x+run > lastx || run > lastx ) - run = runs[0] = (uint32) (lastx - x); + run = runs[0] = (uint32_t) (lastx - x); if (run) { cp = buf + (x>>3); bx = x&7; @@ -427,15 +376,15 @@ _TIFFFax3fillruns(unsigned char* buf, uint32* runs, uint32* erun, uint32 lastx) run -= 8-bx; } if( (n = run >> 3) != 0 ) { /* multiple bytes to fill */ - if ((n/sizeof (long)) > 1) { + if ((n/sizeof (int64_t)) > 1) { /* - * Align to longword boundary and fill. + * Align to int64_tword boundary and fill. */ - for (; n && !isAligned(cp, long); n--) + for (; n && !isAligned(cp, int64_t); n--) *cp++ = 0x00; - lp = (long*) cp; - nw = (int32)(n / sizeof (long)); - n -= nw * sizeof (long); + lp = (int64_t*) cp; + nw = (int32_t)(n / sizeof (int64_t)); + n -= nw * sizeof (int64_t); do { *lp++ = 0L; } while (--nw); @@ -462,15 +411,15 @@ _TIFFFax3fillruns(unsigned char* buf, uint32* runs, uint32* erun, uint32 lastx) run -= 8-bx; } if( (n = run>>3) != 0 ) { /* multiple bytes to fill */ - if ((n/sizeof (long)) > 1) { + if ((n/sizeof (int64_t)) > 1) { /* - * Align to longword boundary and fill. + * Align to int64_t boundary and fill. */ - for (; n && !isAligned(cp, long); n--) + for (; n && !isAligned(cp, int64_t); n--) *cp++ = 0xff; - lp = (long*) cp; - nw = (int32)(n / sizeof (long)); - n -= nw * sizeof (long); + lp = (int64_t*) cp; + nw = (int32_t)(n / sizeof (int64_t)); + n -= nw * sizeof (int64_t); do { *lp++ = -1L; } while (--nw); @@ -515,7 +464,7 @@ Fax3SetupState(TIFF* tif) int needsRefLine; Fax3CodecState* dsp = (Fax3CodecState*) Fax3State(tif); tmsize_t rowbytes; - uint32 rowpixels; + uint32_t rowpixels; if (td->td_bitspersample != 1) { TIFFErrorExt(tif->tif_clientdata, module, @@ -532,11 +481,11 @@ Fax3SetupState(TIFF* tif) rowbytes = TIFFScanlineSize(tif); rowpixels = td->td_imagewidth; } - if ((uint64)rowbytes < ((uint64)rowpixels + 7) / 8) + if ((int64_t)rowbytes < ((int64_t)rowpixels + 7) / 8) { TIFFErrorExt(tif->tif_clientdata, module, - "Inconsistent number of bytes per row : rowbytes=%lu rowpixels=%lu", - (unsigned long)(rowbytes), (unsigned long)(rowpixels)); + "Inconsistent number of bytes per row : rowbytes=%" PRId64 " rowpixels=%" PRIu32, + (int64_t) rowbytes, rowpixels); return (0); } sp->rowbytes = rowbytes; @@ -554,24 +503,24 @@ Fax3SetupState(TIFF* tif) TIFFroundup and TIFFSafeMultiply return zero on integer overflow */ - dsp->runs=(uint32*) NULL; + dsp->runs=(uint32_t*) NULL; dsp->nruns = TIFFroundup_32(rowpixels,32); if (needsRefLine) { - dsp->nruns = TIFFSafeMultiply(uint32,dsp->nruns,2); + dsp->nruns = TIFFSafeMultiply(uint32_t, dsp->nruns, 2); } - if ((dsp->nruns == 0) || (TIFFSafeMultiply(uint32,dsp->nruns,2) == 0)) { + if ((dsp->nruns == 0) || (TIFFSafeMultiply(uint32_t, dsp->nruns, 2) == 0)) { TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "Row pixels integer overflow (rowpixels %u)", + "Row pixels integer overflow (rowpixels %"PRIu32")", rowpixels); return (0); } - dsp->runs = (uint32*) _TIFFCheckMalloc(tif, - TIFFSafeMultiply(uint32,dsp->nruns,2), - sizeof (uint32), - "for Group 3/4 run arrays"); + dsp->runs = (uint32_t*) _TIFFCheckMalloc(tif, + TIFFSafeMultiply(uint32_t, dsp->nruns, 2), + sizeof (uint32_t), + "for Group 3/4 run arrays"); if (dsp->runs == NULL) return (0); - memset( dsp->runs, 0, TIFFSafeMultiply(uint32,dsp->nruns,2)*sizeof(uint32)); + memset( dsp->runs, 0, TIFFSafeMultiply(uint32_t,dsp->nruns,2)*sizeof(uint32_t)); dsp->curruns = dsp->runs; if (needsRefLine) dsp->refruns = dsp->runs + dsp->nruns; @@ -614,7 +563,7 @@ Fax3SetupState(TIFF* tif) if( !TIFFFlushData1(tif) ) \ return 0; \ } \ - *(tif)->tif_rawcp++ = (uint8) (sp)->data; \ + *(tif)->tif_rawcp++ = (uint8_t) (sp)->data; \ (tif)->tif_rawcc++; \ (sp)->data = 0, (sp)->bit = 8; \ } @@ -623,7 +572,7 @@ Fax3SetupState(TIFF* tif) if( !TIFFFlushData1(tif) ) \ return 0; \ } \ - *(tif)->tif_rawcp++ = (uint8) data; \ + *(tif)->tif_rawcp++ = (uint8_t) data; \ (tif)->tif_rawcc++; \ data = 0, bit = 8; \ } @@ -670,7 +619,7 @@ Fax3PutBits(TIFF* tif, unsigned int bits, unsigned int length) #define DEBUG_COLOR(w) (tab == TIFFFaxWhiteCodes ? w "W" : w "B") #define DEBUG_PRINT(what,len) { \ int t; \ - printf("%08X/%-2d: %s%5d\t", data, bit, DEBUG_COLOR(what), len); \ + printf("%08"PRIX32"/%-2d: %s%5d\t", data, bit, DEBUG_COLOR(what), len); \ for (t = length-1; t >= 0; t--) \ putchar(code & (1<<t) ? '1' : '0'); \ putchar('\n'); \ @@ -684,7 +633,7 @@ Fax3PutBits(TIFF* tif, unsigned int bits, unsigned int length) * terminating codes is supplied. */ static int -putspan(TIFF* tif, int32 span, const tableentry* tab) +putspan(TIFF* tif, int32_t span, const tableentry* tab) { Fax3CodecState* sp = EncoderState(tif); unsigned int bit = sp->bit; @@ -773,7 +722,7 @@ Fax3PutEOL(TIFF* tif) * Reset encoding state at the start of a strip. */ static int -Fax3PreEncode(TIFF* tif, uint16 s) +Fax3PreEncode(TIFF* tif, uint16_t s) { Fax3CodecState* sp = EncoderState(tif); @@ -849,25 +798,15 @@ static const unsigned char oneruns[256] = { }; /* - * On certain systems it pays to inline - * the routines that find pixel spans. - */ -#ifdef VAXC -static int32 find0span(unsigned char*, int32, int32); -static int32 find1span(unsigned char*, int32, int32); -#pragma inline(find0span,find1span) -#endif - -/* * Find a span of ones or zeros using the supplied * table. The ``base'' of the bit string is supplied * along with the start+end bit indices. */ -inline static int32 -find0span(unsigned char* bp, int32 bs, int32 be) +static inline int32_t +find0span(unsigned char* bp, int32_t bs, int32_t be) { - int32 bits = be - bs; - int32 n, span; + int32_t bits = be - bs; + int32_t n, span; bp += bs>>3; /* @@ -885,22 +824,22 @@ find0span(unsigned char* bp, int32 bs, int32 be) bp++; } else span = 0; - if (bits >= (int32)(2 * 8 * sizeof(long))) { - long* lp; + if (bits >= (int32_t)(2 * 8 * sizeof(int64_t))) { + int64_t* lp; /* - * Align to longword boundary and check longwords. + * Align to int64_t boundary and check int64_t words. */ - while (!isAligned(bp, long)) { + while (!isAligned(bp, int64_t)) { if (*bp != 0x00) return (span + zeroruns[*bp]); span += 8; bits -= 8; bp++; } - lp = (long*) bp; - while ((bits >= (int32)(8 * sizeof(long))) && (0 == *lp)) { - span += 8*sizeof (long); - bits -= 8*sizeof (long); + lp = (int64_t*) bp; + while ((bits >= (int32_t)(8 * sizeof(int64_t))) && (0 == *lp)) { + span += 8*sizeof (int64_t); + bits -= 8*sizeof (int64_t); lp++; } bp = (unsigned char*) lp; @@ -925,11 +864,11 @@ find0span(unsigned char* bp, int32 bs, int32 be) return (span); } -inline static int32 -find1span(unsigned char* bp, int32 bs, int32 be) +static inline int32_t +find1span(unsigned char* bp, int32_t bs, int32_t be) { - int32 bits = be - bs; - int32 n, span; + int32_t bits = be - bs; + int32_t n, span; bp += bs>>3; /* @@ -947,22 +886,22 @@ find1span(unsigned char* bp, int32 bs, int32 be) bp++; } else span = 0; - if (bits >= (int32)(2 * 8 * sizeof(long))) { - long* lp; + if (bits >= (int32_t)(2 * 8 * sizeof(int64_t))) { + int64_t* lp; /* - * Align to longword boundary and check longwords. + * Align to int64_t boundary and check int64_t words. */ - while (!isAligned(bp, long)) { + while (!isAligned(bp, int64_t)) { if (*bp != 0xff) return (span + oneruns[*bp]); span += 8; bits -= 8; bp++; } - lp = (long*) bp; - while ((bits >= (int32)(8 * sizeof(long))) && (~0 == *lp)) { - span += 8*sizeof (long); - bits -= 8*sizeof (long); + lp = (int64_t*) bp; + while ((bits >= (int32_t)(8 * sizeof(int64_t))) && (~((uint64_t)0) == (uint64_t)*lp)) { + span += 8*sizeof (int64_t); + bits -= 8*sizeof (int64_t); lp++; } bp = (unsigned char*) lp; @@ -1008,11 +947,11 @@ find1span(unsigned char* bp, int32 bs, int32 be) * of pixels encoded with Huffman codes. */ static int -Fax3Encode1DRow(TIFF* tif, unsigned char* bp, uint32 bits) +Fax3Encode1DRow(TIFF* tif, unsigned char* bp, uint32_t bits) { Fax3CodecState* sp = EncoderState(tif); - int32 span; - uint32 bs = 0; + int32_t span; + uint32_t bs = 0; for (;;) { span = find0span(bp, bs, bits); /* white span */ @@ -1032,7 +971,7 @@ Fax3Encode1DRow(TIFF* tif, unsigned char* bp, uint32 bits) if (sp->bit != 8) /* byte-align */ Fax3FlushBits(tif, sp); if ((sp->b.mode&FAXMODE_WORDALIGN) && - !isAligned(tif->tif_rawcp, uint16)) + !isAligned(tif->tif_rawcp, uint16_t)) Fax3FlushBits(tif, sp); } return (1); @@ -1057,22 +996,22 @@ static const tableentry vcodes[7] = { * documentation for the algorithm. */ static int -Fax3Encode2DRow(TIFF* tif, unsigned char* bp, unsigned char* rp, uint32 bits) +Fax3Encode2DRow(TIFF* tif, unsigned char* bp, unsigned char* rp, uint32_t bits) { #define PIXEL(buf,ix) ((((buf)[(ix)>>3]) >> (7-((ix)&7))) & 1) - uint32 a0 = 0; - uint32 a1 = (PIXEL(bp, 0) != 0 ? 0 : finddiff(bp, 0, bits, 0)); - uint32 b1 = (PIXEL(rp, 0) != 0 ? 0 : finddiff(rp, 0, bits, 0)); - uint32 a2, b2; + uint32_t a0 = 0; + uint32_t a1 = (PIXEL(bp, 0) != 0 ? 0 : finddiff(bp, 0, bits, 0)); + uint32_t b1 = (PIXEL(rp, 0) != 0 ? 0 : finddiff(rp, 0, bits, 0)); + uint32_t a2, b2; for (;;) { b2 = finddiff2(rp, b1, bits, PIXEL(rp,b1)); if (b2 >= a1) { /* Naive computation triggers -fsanitize=undefined,unsigned-integer-overflow */ /* although it is correct unless the difference between both is < 31 bit */ - /* int32 d = b1 - a1; */ - int32 d = (b1 >= a1 && b1 - a1 <= 3U) ? (int32)(b1 - a1): - (b1 < a1 && a1 - b1 <= 3U) ? -(int32)(a1 - b1) : 0x7FFFFFFF; + /* int32_t d = b1 - a1; */ + int32_t d = (b1 >= a1 && b1 - a1 <= 3U) ? (int32_t)(b1 - a1) : + (b1 < a1 && a1 - b1 <= 3U) ? -(int32_t)(a1 - b1) : 0x7FFFFFFF; if (!(-3 <= d && d <= 3)) { /* horizontal mode */ a2 = finddiff2(bp, a1, bits, PIXEL(bp,a1)); if( !putcode(tif, &horizcode) ) @@ -1113,7 +1052,7 @@ Fax3Encode2DRow(TIFF* tif, unsigned char* bp, unsigned char* rp, uint32 bits) * Encode a buffer of pixels. */ static int -Fax3Encode(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) +Fax3Encode(TIFF* tif, uint8_t* bp, tmsize_t cc, uint16_t s) { static const char module[] = "Fax3Encode"; Fax3CodecState* sp = EncoderState(tif); @@ -1233,7 +1172,7 @@ static const TIFFField fax4Fields[] = { }; static int -Fax3VSetField(TIFF* tif, uint32 tag, va_list ap) +Fax3VSetField(TIFF* tif, uint32_t tag, va_list ap) { Fax3BaseState* sp = Fax3State(tif); const TIFFField* fip; @@ -1251,21 +1190,21 @@ Fax3VSetField(TIFF* tif, uint32 tag, va_list ap) case TIFFTAG_GROUP3OPTIONS: /* XXX: avoid reading options if compression mismatches. */ if (tif->tif_dir.td_compression == COMPRESSION_CCITTFAX3) - sp->groupoptions = (uint32) va_arg(ap, uint32); + sp->groupoptions = (uint32_t) va_arg(ap, uint32_t); break; case TIFFTAG_GROUP4OPTIONS: /* XXX: avoid reading options if compression mismatches. */ if (tif->tif_dir.td_compression == COMPRESSION_CCITTFAX4) - sp->groupoptions = (uint32) va_arg(ap, uint32); + sp->groupoptions = (uint32_t) va_arg(ap, uint32_t); break; case TIFFTAG_BADFAXLINES: - sp->badfaxlines = (uint32) va_arg(ap, uint32); + sp->badfaxlines = (uint32_t) va_arg(ap, uint32_t); break; case TIFFTAG_CLEANFAXDATA: - sp->cleanfaxdata = (uint16) va_arg(ap, uint16_vap); + sp->cleanfaxdata = (uint16_t) va_arg(ap, uint16_vap); break; case TIFFTAG_CONSECUTIVEBADFAXLINES: - sp->badfaxrun = (uint32) va_arg(ap, uint32); + sp->badfaxrun = (uint32_t) va_arg(ap, uint32_t); break; default: return (*sp->vsetparent)(tif, tag, ap); @@ -1281,7 +1220,7 @@ Fax3VSetField(TIFF* tif, uint32 tag, va_list ap) } static int -Fax3VGetField(TIFF* tif, uint32 tag, va_list ap) +Fax3VGetField(TIFF* tif, uint32_t tag, va_list ap) { Fax3BaseState* sp = Fax3State(tif); @@ -1296,16 +1235,16 @@ Fax3VGetField(TIFF* tif, uint32 tag, va_list ap) break; case TIFFTAG_GROUP3OPTIONS: case TIFFTAG_GROUP4OPTIONS: - *va_arg(ap, uint32*) = sp->groupoptions; + *va_arg(ap, uint32_t*) = sp->groupoptions; break; case TIFFTAG_BADFAXLINES: - *va_arg(ap, uint32*) = sp->badfaxlines; + *va_arg(ap, uint32_t*) = sp->badfaxlines; break; case TIFFTAG_CLEANFAXDATA: - *va_arg(ap, uint16*) = sp->cleanfaxdata; + *va_arg(ap, uint16_t*) = sp->cleanfaxdata; break; case TIFFTAG_CONSECUTIVEBADFAXLINES: - *va_arg(ap, uint32*) = sp->badfaxrun; + *va_arg(ap, uint32_t*) = sp->badfaxrun; break; default: return (*sp->vgetparent)(tif, tag, ap); @@ -1341,9 +1280,9 @@ Fax3PrintDir(TIFF* tif, FILE* fd, long flags) if (sp->groupoptions & GROUP3OPT_UNCOMPRESSED) fprintf(fd, "%suncompressed data", sep); } - fprintf(fd, " (%lu = 0x%lx)\n", - (unsigned long) sp->groupoptions, - (unsigned long) sp->groupoptions); + fprintf(fd, " (%" PRIu32 " = 0x%" PRIx32 ")\n", + sp->groupoptions, + sp->groupoptions); } if (TIFFFieldSet(tif,FIELD_CLEANFAXDATA)) { fprintf(fd, " Fax Data:"); @@ -1358,15 +1297,15 @@ Fax3PrintDir(TIFF* tif, FILE* fd, long flags) fprintf(fd, " uncorrected errors"); break; } - fprintf(fd, " (%u = 0x%x)\n", + fprintf(fd, " (%"PRIu16" = 0x%"PRIx16")\n", sp->cleanfaxdata, sp->cleanfaxdata); } if (TIFFFieldSet(tif,FIELD_BADFAXLINES)) - fprintf(fd, " Bad Fax Lines: %lu\n", - (unsigned long) sp->badfaxlines); + fprintf(fd, " Bad Fax Lines: %" PRIu32 "\n", + sp->badfaxlines); if (TIFFFieldSet(tif,FIELD_BADFAXRUN)) - fprintf(fd, " Consecutive Bad Fax Lines: %lu\n", - (unsigned long) sp->badfaxrun); + fprintf(fd, " Consecutive Bad Fax Lines: %" PRIu32 "\n", + sp->badfaxrun); if (sp->printdir) (*sp->printdir)(tif, fd, flags); } @@ -1389,7 +1328,7 @@ InitCCITTFax3(TIFF* tif) /* * Allocate state block so tag methods have storage to record values. */ - tif->tif_data = (uint8*) + tif->tif_data = (uint8_t*) _TIFFmalloc(sizeof (Fax3CodecState)); if (tif->tif_data == NULL) { @@ -1473,7 +1412,7 @@ TIFFInitCCITTFax3(TIFF* tif, int scheme) * Decode the requested amount of G4-encoded data. */ static int -Fax4Decode(TIFF* tif, uint8* buf, tmsize_t occ, uint16 s) +Fax4Decode(TIFF* tif, uint8_t* buf, tmsize_t occ, uint16_t s) { DECLARE_STATE_2D(tif, sp, "Fax4Decode"); (void) s; @@ -1490,7 +1429,7 @@ Fax4Decode(TIFF* tif, uint8* buf, tmsize_t occ, uint16 s) pb = sp->refruns; b1 = *pb++; #ifdef FAX3_DEBUG - printf("\nBitAcc=%08X, BitsAvail = %d\n", BitAcc, BitsAvail); + printf("\nBitAcc=%08"PRIX32", BitsAvail = %d\n", BitAcc, BitsAvail); printf("-------------------- %d\n", tif->tif_row); fflush(stdout); #endif @@ -1500,13 +1439,13 @@ Fax4Decode(TIFF* tif, uint8* buf, tmsize_t occ, uint16 s) if (((lastx + 7) >> 3) > (int)occ) /* check for buffer overrun */ { TIFFErrorExt(tif->tif_clientdata, module, - "Buffer overrun detected : %d bytes available, %d bits needed", - (int)occ, lastx); + "Buffer overrun detected : %"TIFF_SSIZE_FORMAT" bytes available, %d bits needed", + occ, lastx); return -1; } (*sp->fill)(buf, thisrun, pa, lastx); SETVALUE(0); /* imaginary change for reference */ - SWAP(uint32*, sp->curruns, sp->refruns); + SWAP(uint32_t*, sp->curruns, sp->refruns); buf += sp->b.rowbytes; occ -= sp->b.rowbytes; sp->line++; @@ -1522,8 +1461,8 @@ Fax4Decode(TIFF* tif, uint8* buf, tmsize_t occ, uint16 s) if (((lastx + 7) >> 3) > (int)occ) /* check for buffer overrun */ { TIFFErrorExt(tif->tif_clientdata, module, - "Buffer overrun detected : %d bytes available, %d bits needed", - (int)occ, lastx); + "Buffer overrun detected : %"TIFF_SSIZE_FORMAT" bytes available, %d bits needed", + occ, lastx); return -1; } (*sp->fill)(buf, thisrun, pa, lastx); @@ -1539,7 +1478,7 @@ Fax4Decode(TIFF* tif, uint8* buf, tmsize_t occ, uint16 s) * Encode the requested amount of data. */ static int -Fax4Encode(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) +Fax4Encode(TIFF* tif, uint8_t* bp, tmsize_t cc, uint16_t s) { static const char module[] = "Fax4Encode"; Fax3CodecState *sp = EncoderState(tif); @@ -1611,7 +1550,7 @@ TIFFInitCCITTFax4(TIFF* tif, int scheme) * Decode the requested amount of RLE-encoded data. */ static int -Fax3DecodeRLE(TIFF* tif, uint8* buf, tmsize_t occ, uint16 s) +Fax3DecodeRLE(TIFF* tif, uint8_t* buf, tmsize_t occ, uint16_t s) { DECLARE_STATE(tif, sp, "Fax3DecodeRLE"); int mode = sp->b.mode; @@ -1628,8 +1567,8 @@ Fax3DecodeRLE(TIFF* tif, uint8* buf, tmsize_t occ, uint16 s) RunLength = 0; pa = thisrun; #ifdef FAX3_DEBUG - printf("\nBitAcc=%08X, BitsAvail = %d\n", BitAcc, BitsAvail); - printf("-------------------- %d\n", tif->tif_row); + printf("\nBitAcc=%08"PRIX32", BitsAvail = %d\n", BitAcc, BitsAvail); + printf("-------------------- %"PRIu32"\n", tif->tif_row); fflush(stdout); #endif EXPAND1D(EOFRLE); @@ -1643,7 +1582,7 @@ Fax3DecodeRLE(TIFF* tif, uint8* buf, tmsize_t occ, uint16 s) } else if (mode & FAXMODE_WORDALIGN) { int n = BitsAvail - (BitsAvail &~ 15); ClrBits(n); - if (BitsAvail == 0 && !isAligned(cp, uint16)) + if (BitsAvail == 0 && !isAligned(cp, uint16_t)) cp++; } buf += sp->b.rowbytes; diff --git a/tiff/libtiff/tif_fax3.h b/tiff/libtiff/tif_fax3.h index 701716cc..fdafe492 100644 --- a/tiff/libtiff/tif_fax3.h +++ b/tiff/libtiff/tif_fax3.h @@ -41,7 +41,7 @@ * The routine must have the type signature given below; * for example: * - * fillruns(unsigned char* buf, uint32* runs, uint32* erun, uint32 lastx) + * fillruns(unsigned char* buf, uint32_t* runs, uint32_t* erun, uint32_t lastx) * * where buf is place to set the bits, runs is the array of b&w run * lengths (white then black), erun is the last run in the array, and @@ -50,7 +50,7 @@ * data in the run array as needed (e.g. to append zero runs to bring * the count up to a nice multiple). */ -typedef void (*TIFFFaxFillFunc)(unsigned char*, uint32*, uint32*, uint32); +typedef void (*TIFFFaxFillFunc)(unsigned char*, uint32_t*, uint32_t*, uint32_t); /* * The default run filler; made external for other decoders. @@ -58,7 +58,7 @@ typedef void (*TIFFFaxFillFunc)(unsigned char*, uint32*, uint32*, uint32); #if defined(__cplusplus) extern "C" { #endif -extern void _TIFFFax3fillruns(unsigned char*, uint32*, uint32*, uint32); +extern void _TIFFFax3fillruns(unsigned char*, uint32_t*, uint32_t*, uint32_t); #if defined(__cplusplus) } #endif @@ -84,7 +84,7 @@ extern void _TIFFFax3fillruns(unsigned char*, uint32*, uint32*, uint32); typedef struct { /* state table entry */ unsigned char State; /* see above */ unsigned char Width; /* width of code in bits */ - uint32 Param; /* unsigned 32-bit run length in bits (holds on 16 bit actually, but cannot be changed. See above warning) */ + uint32_t Param; /* unsigned 32-bit run length in bits (holds on 16 bit actually, but cannot be changed. See above warning) */ } TIFFFaxTabEnt; extern const TIFFFaxTabEnt TIFFFaxMainTable[]; @@ -141,7 +141,7 @@ extern const TIFFFaxTabEnt TIFFFaxBlackTable[]; goto eoflab; \ BitsAvail = (n); /* pad with zeros */ \ } else { \ - BitAcc |= ((uint32) bitmap[*cp++])<<BitsAvail; \ + BitAcc |= ((uint32_t) bitmap[*cp++])<<BitsAvail; \ BitsAvail += 8; \ } \ } \ @@ -155,13 +155,13 @@ extern const TIFFFaxTabEnt TIFFFaxBlackTable[]; goto eoflab; \ BitsAvail = (n); /* pad with zeros */ \ } else { \ - BitAcc |= ((uint32) bitmap[*cp++])<<BitsAvail; \ + BitAcc |= ((uint32_t) bitmap[*cp++])<<BitsAvail; \ if ((BitsAvail += 8) < (n)) { \ if (EndOfData()) { \ /* NB: we know BitsAvail is non-zero here */ \ BitsAvail = (n); /* pad with zeros */ \ } else { \ - BitAcc |= ((uint32) bitmap[*cp++])<<BitsAvail; \ + BitAcc |= ((uint32_t) bitmap[*cp++])<<BitsAvail; \ BitsAvail += 8; \ } \ } \ diff --git a/tiff/libtiff/tif_getimage.c b/tiff/libtiff/tif_getimage.c index 3460af74..a1b6570b 100644 --- a/tiff/libtiff/tif_getimage.c +++ b/tiff/libtiff/tif_getimage.c @@ -31,10 +31,10 @@ #include <stdio.h> #include <limits.h> -static int gtTileContig(TIFFRGBAImage*, uint32*, uint32, uint32); -static int gtTileSeparate(TIFFRGBAImage*, uint32*, uint32, uint32); -static int gtStripContig(TIFFRGBAImage*, uint32*, uint32, uint32); -static int gtStripSeparate(TIFFRGBAImage*, uint32*, uint32, uint32); +static int gtTileContig(TIFFRGBAImage*, uint32_t*, uint32_t, uint32_t); +static int gtTileSeparate(TIFFRGBAImage*, uint32_t*, uint32_t, uint32_t); +static int gtStripContig(TIFFRGBAImage*, uint32_t*, uint32_t, uint32_t); +static int gtStripSeparate(TIFFRGBAImage*, uint32_t*, uint32_t, uint32_t); static int PickContigCase(TIFFRGBAImage*); static int PickSeparateCase(TIFFRGBAImage*); @@ -75,7 +75,7 @@ int TIFFRGBAImageOK(TIFF* tif, char emsg[1024]) { TIFFDirectory* td = &tif->tif_dir; - uint16 photometric; + uint16_t photometric; int colorchannels; if (!tif->tif_decodestatus) { @@ -90,7 +90,7 @@ TIFFRGBAImageOK(TIFF* tif, char emsg[1024]) case 16: break; default: - sprintf(emsg, "Sorry, can not handle images with %d-bit samples", + sprintf(emsg, "Sorry, can not handle images with %"PRIu16"-bit samples", td->td_bitspersample); return (0); } @@ -120,8 +120,8 @@ TIFFRGBAImageOK(TIFF* tif, char emsg[1024]) && td->td_samplesperpixel != 1 && td->td_bitspersample < 8 ) { sprintf(emsg, - "Sorry, can not handle contiguous data with %s=%d, " - "and %s=%d and Bits/Sample=%d", + "Sorry, can not handle contiguous data with %s=%"PRIu16", " + "and %s=%"PRIu16" and Bits/Sample=%"PRIu16"", photoTag, photometric, "Samples/pixel", td->td_samplesperpixel, td->td_bitspersample); @@ -150,7 +150,7 @@ TIFFRGBAImageOK(TIFF* tif, char emsg[1024]) break; case PHOTOMETRIC_SEPARATED: { - uint16 inkset; + uint16_t inkset; TIFFGetFieldDefaulted(tif, TIFFTAG_INKSET, &inkset); if (inkset != INKSET_CMYK) { sprintf(emsg, @@ -160,7 +160,7 @@ TIFFRGBAImageOK(TIFF* tif, char emsg[1024]) } if (td->td_samplesperpixel < 4) { sprintf(emsg, - "Sorry, can not handle separated image with %s=%d", + "Sorry, can not handle separated image with %s=%"PRIu16, "Samples/pixel", td->td_samplesperpixel); return 0; } @@ -181,13 +181,13 @@ TIFFRGBAImageOK(TIFF* tif, char emsg[1024]) return (0); } if (td->td_planarconfig != PLANARCONFIG_CONTIG) { - sprintf(emsg, "Sorry, can not handle LogLuv images with %s=%d", + sprintf(emsg, "Sorry, can not handle LogLuv images with %s=%"PRIu16, "Planarconfiguration", td->td_planarconfig); return (0); } if ( td->td_samplesperpixel != 3 || colorchannels != 3 ) { sprintf(emsg, - "Sorry, can not handle image with %s=%d, %s=%d", + "Sorry, can not handle image with %s=%"PRIu16", %s=%d", "Samples/pixel", td->td_samplesperpixel, "colorchannels", colorchannels); return 0; @@ -196,7 +196,7 @@ TIFFRGBAImageOK(TIFF* tif, char emsg[1024]) case PHOTOMETRIC_CIELAB: if ( td->td_samplesperpixel != 3 || colorchannels != 3 || td->td_bitspersample != 8 ) { sprintf(emsg, - "Sorry, can not handle image with %s=%d, %s=%d and %s=%d", + "Sorry, can not handle image with %s=%"PRIu16", %s=%d and %s=%"PRIu16, "Samples/pixel", td->td_samplesperpixel, "colorchannels", colorchannels, "Bits/sample", td->td_bitspersample); @@ -204,7 +204,7 @@ TIFFRGBAImageOK(TIFF* tif, char emsg[1024]) } break; default: - sprintf(emsg, "Sorry, can not handle image with %s=%d", + sprintf(emsg, "Sorry, can not handle image with %s=%"PRIu16, photoTag, photometric); return (0); } @@ -254,7 +254,7 @@ TIFFRGBAImageEnd(TIFFRGBAImage* img) static int isCCITTCompression(TIFF* tif) { - uint16 compress; + uint16_t compress; TIFFGetField(tif, TIFFTAG_COMPRESSION, &compress); return (compress == COMPRESSION_CCITTFAX3 || compress == COMPRESSION_CCITTFAX4 || @@ -265,12 +265,12 @@ isCCITTCompression(TIFF* tif) int TIFFRGBAImageBegin(TIFFRGBAImage* img, TIFF* tif, int stop, char emsg[1024]) { - uint16* sampleinfo; - uint16 extrasamples; - uint16 planarconfig; - uint16 compress; + uint16_t* sampleinfo; + uint16_t extrasamples; + uint16_t planarconfig; + uint16_t compress; int colorchannels; - uint16 *red_orig, *green_orig, *blue_orig; + uint16_t *red_orig, *green_orig, *blue_orig; int n_color; if( !TIFFRGBAImageOK(tif, emsg) ) @@ -302,7 +302,7 @@ TIFFRGBAImageBegin(TIFFRGBAImage* img, TIFF* tif, int stop, char emsg[1024]) case 16: break; default: - sprintf(emsg, "Sorry, can not handle images with %d-bit samples", + sprintf(emsg, "Sorry, can not handle images with %"PRIu16"-bit samples", img->bitspersample); goto fail_return; } @@ -366,9 +366,9 @@ TIFFRGBAImageBegin(TIFFRGBAImage* img, TIFF* tif, int stop, char emsg[1024]) /* copy the colormaps so we can modify them */ n_color = (1U << img->bitspersample); - img->redcmap = (uint16 *) _TIFFmalloc(sizeof(uint16)*n_color); - img->greencmap = (uint16 *) _TIFFmalloc(sizeof(uint16)*n_color); - img->bluecmap = (uint16 *) _TIFFmalloc(sizeof(uint16)*n_color); + img->redcmap = (uint16_t *) _TIFFmalloc(sizeof(uint16_t) * n_color); + img->greencmap = (uint16_t *) _TIFFmalloc(sizeof(uint16_t) * n_color); + img->bluecmap = (uint16_t *) _TIFFmalloc(sizeof(uint16_t) * n_color); if( !img->redcmap || !img->greencmap || !img->bluecmap ) { sprintf(emsg, "Out of memory for colormap copy"); goto fail_return; @@ -385,8 +385,8 @@ TIFFRGBAImageBegin(TIFFRGBAImage* img, TIFF* tif, int stop, char emsg[1024]) && img->samplesperpixel != 1 && img->bitspersample < 8 ) { sprintf(emsg, - "Sorry, can not handle contiguous data with %s=%d, " - "and %s=%d and Bits/Sample=%d", + "Sorry, can not handle contiguous data with %s=%"PRIu16", " + "and %s=%"PRIu16" and Bits/Sample=%"PRIu16, photoTag, img->photometric, "Samples/pixel", img->samplesperpixel, img->bitspersample); @@ -428,15 +428,15 @@ TIFFRGBAImageBegin(TIFFRGBAImage* img, TIFF* tif, int stop, char emsg[1024]) break; case PHOTOMETRIC_SEPARATED: { - uint16 inkset; + uint16_t inkset; TIFFGetFieldDefaulted(tif, TIFFTAG_INKSET, &inkset); if (inkset != INKSET_CMYK) { - sprintf(emsg, "Sorry, can not handle separated image with %s=%d", + sprintf(emsg, "Sorry, can not handle separated image with %s=%"PRIu16, "InkSet", inkset); goto fail_return; } if (img->samplesperpixel < 4) { - sprintf(emsg, "Sorry, can not handle separated image with %s=%d", + sprintf(emsg, "Sorry, can not handle separated image with %s=%"PRIu16, "Samples/pixel", img->samplesperpixel); goto fail_return; } @@ -459,7 +459,7 @@ TIFFRGBAImageBegin(TIFFRGBAImage* img, TIFF* tif, int stop, char emsg[1024]) goto fail_return; } if (planarconfig != PLANARCONFIG_CONTIG) { - sprintf(emsg, "Sorry, can not handle LogLuv images with %s=%d", + sprintf(emsg, "Sorry, can not handle LogLuv images with %s=%"PRIu16, "Planarconfiguration", planarconfig); return (0); } @@ -470,7 +470,7 @@ TIFFRGBAImageBegin(TIFFRGBAImage* img, TIFF* tif, int stop, char emsg[1024]) case PHOTOMETRIC_CIELAB: break; default: - sprintf(emsg, "Sorry, can not handle image with %s=%d", + sprintf(emsg, "Sorry, can not handle image with %s=%"PRIu16, photoTag, img->photometric); goto fail_return; } @@ -498,7 +498,7 @@ TIFFRGBAImageBegin(TIFFRGBAImage* img, TIFF* tif, int stop, char emsg[1024]) } int -TIFFRGBAImageGet(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h) +TIFFRGBAImageGet(TIFFRGBAImage* img, uint32_t* raster, uint32_t w, uint32_t h) { if (img->get == NULL) { TIFFErrorExt(img->tif->tif_clientdata, TIFFFileName(img->tif), "No \"get\" routine setup"); @@ -518,15 +518,15 @@ TIFFRGBAImageGet(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h) */ int TIFFReadRGBAImageOriented(TIFF* tif, - uint32 rwidth, uint32 rheight, uint32* raster, - int orientation, int stop) + uint32_t rwidth, uint32_t rheight, uint32_t* raster, + int orientation, int stop) { char emsg[1024] = ""; TIFFRGBAImage img; int ok; if (TIFFRGBAImageOK(tif, emsg) && TIFFRGBAImageBegin(&img, tif, stop, emsg)) { - img.req_orientation = (uint16)orientation; + img.req_orientation = (uint16_t)orientation; /* XXX verify rwidth and rheight against width and height */ ok = TIFFRGBAImageGet(&img, raster+(rheight-img.height)*rwidth, rwidth, img.height); @@ -544,7 +544,7 @@ TIFFReadRGBAImageOriented(TIFF* tif, */ int TIFFReadRGBAImage(TIFF* tif, - uint32 rwidth, uint32 rheight, uint32* raster, int stop) + uint32_t rwidth, uint32_t rheight, uint32_t* raster, int stop) { return TIFFReadRGBAImageOriented(tif, rwidth, rheight, raster, ORIENTATION_BOTLEFT, stop); @@ -618,21 +618,21 @@ setorientation(TIFFRGBAImage* img) * SamplesPerPixel == 1 */ static int -gtTileContig(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h) +gtTileContig(TIFFRGBAImage* img, uint32_t* raster, uint32_t w, uint32_t h) { TIFF* tif = img->tif; tileContigRoutine put = img->put.contig; - uint32 col, row, y, rowstoread; + uint32_t col, row, y, rowstoread; tmsize_t pos; - uint32 tw, th; + uint32_t tw, th; unsigned char* buf = NULL; - int32 fromskew, toskew; - uint32 nrow; + int32_t fromskew, toskew; + uint32_t nrow; int ret = 1, flip; - uint32 this_tw, tocol; - int32 this_toskew, leftmost_toskew; - int32 leftmost_fromskew; - uint32 leftmost_tw; + uint32_t this_tw, tocol; + int32_t this_toskew, leftmost_toskew; + int32_t leftmost_fromskew; + uint32_t leftmost_tw; tmsize_t bufsize; bufsize = TIFFTileSize(tif); @@ -651,7 +651,7 @@ gtTileContig(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h) return (0); } y = h - 1; - toskew = -(int32)(tw + w); + toskew = -(int32_t)(tw + w); } else { if (tw > (INT_MAX + w)) { @@ -659,7 +659,7 @@ gtTileContig(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h) return (0); } y = 0; - toskew = -(int32)(tw - w); + toskew = -(int32_t)(tw - w); } /* @@ -708,19 +708,19 @@ gtTileContig(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h) this_toskew = toskew; } - y += ((flip & FLIP_VERTICALLY) ? -(int32) nrow : (int32) nrow); + y += ((flip & FLIP_VERTICALLY) ? -(int32_t) nrow : (int32_t) nrow); } _TIFFfree(buf); if (flip & FLIP_HORIZONTALLY) { - uint32 line; + uint32_t line; for (line = 0; line < h; line++) { - uint32 *left = raster + (line * w); - uint32 *right = left + w - 1; + uint32_t *left = raster + (line * w); + uint32_t *right = left + w - 1; while ( left < right ) { - uint32 temp = *left; + uint32_t temp = *left; *left = *right; *right = temp; left++; @@ -739,13 +739,13 @@ gtTileContig(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h) * We assume that all such images are RGB. */ static int -gtTileSeparate(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h) +gtTileSeparate(TIFFRGBAImage* img, uint32_t* raster, uint32_t w, uint32_t h) { TIFF* tif = img->tif; tileSeparateRoutine put = img->put.separate; - uint32 col, row, y, rowstoread; + uint32_t col, row, y, rowstoread; tmsize_t pos; - uint32 tw, th; + uint32_t tw, th; unsigned char* buf = NULL; unsigned char* p0 = NULL; unsigned char* p1 = NULL; @@ -753,15 +753,15 @@ gtTileSeparate(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h) unsigned char* pa = NULL; tmsize_t tilesize; tmsize_t bufsize; - int32 fromskew, toskew; + int32_t fromskew, toskew; int alpha = img->alpha; - uint32 nrow; + uint32_t nrow; int ret = 1, flip; - uint16 colorchannels; - uint32 this_tw, tocol; - int32 this_toskew, leftmost_toskew; - int32 leftmost_fromskew; - uint32 leftmost_tw; + uint16_t colorchannels; + uint32_t this_tw, tocol; + int32_t this_toskew, leftmost_toskew; + int32_t leftmost_fromskew; + uint32_t leftmost_tw; tilesize = TIFFTileSize(tif); bufsize = _TIFFMultiplySSize(tif, alpha?4:3,tilesize, "gtTileSeparate"); @@ -779,7 +779,7 @@ gtTileSeparate(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h) return (0); } y = h - 1; - toskew = -(int32)(tw + w); + toskew = -(int32_t)(tw + w); } else { if (tw > (INT_MAX + w)) { @@ -787,7 +787,7 @@ gtTileSeparate(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h) return (0); } y = 0; - toskew = -(int32)(tw - w); + toskew = -(int32_t)(tw - w); } switch( img->photometric ) @@ -897,18 +897,18 @@ gtTileSeparate(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h) this_toskew = toskew; } - y += ((flip & FLIP_VERTICALLY) ?-(int32) nrow : (int32) nrow); + y += ((flip & FLIP_VERTICALLY) ? -(int32_t) nrow : (int32_t) nrow); } if (flip & FLIP_HORIZONTALLY) { - uint32 line; + uint32_t line; for (line = 0; line < h; line++) { - uint32 *left = raster + (line * w); - uint32 *right = left + w - 1; + uint32_t *left = raster + (line * w); + uint32_t *right = left + w - 1; while ( left < right ) { - uint32 temp = *left; + uint32_t temp = *left; *left = *right; *right = temp; left++; @@ -928,18 +928,18 @@ gtTileSeparate(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h) * SamplesPerPixel == 1 */ static int -gtStripContig(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h) +gtStripContig(TIFFRGBAImage* img, uint32_t* raster, uint32_t w, uint32_t h) { TIFF* tif = img->tif; tileContigRoutine put = img->put.contig; - uint32 row, y, nrow, nrowsub, rowstoread; + uint32_t row, y, nrow, nrowsub, rowstoread; tmsize_t pos; unsigned char* buf = NULL; - uint32 rowsperstrip; - uint16 subsamplinghor,subsamplingver; - uint32 imagewidth = img->width; + uint32_t rowsperstrip; + uint16_t subsamplinghor,subsamplingver; + uint32_t imagewidth = img->width; tmsize_t scanline; - int32 fromskew, toskew; + int32_t fromskew, toskew; int ret = 1, flip; tmsize_t maxstripsize; @@ -958,10 +958,10 @@ gtStripContig(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h) return (0); } y = h - 1; - toskew = -(int32)(w + w); + toskew = -(int32_t)(w + w); } else { y = 0; - toskew = -(int32)(w - w); + toskew = -(int32_t)(w - w); } TIFFGetFieldDefaulted(tif, TIFFTAG_ROWSPERSTRIP, &rowsperstrip); @@ -970,7 +970,7 @@ gtStripContig(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h) fromskew = (w < imagewidth ? imagewidth - w : 0); for (row = 0; row < h; row += nrow) { - uint32 temp; + uint32_t temp; rowstoread = rowsperstrip - (row + img->row_offset) % rowsperstrip; nrow = (row + rowstoread > h ? h - row : rowstoread); nrowsub = nrow; @@ -996,18 +996,18 @@ gtStripContig(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h) pos = ((row + img->row_offset) % rowsperstrip) * scanline + \ ((tmsize_t) img->col_offset * img->samplesperpixel); (*put)(img, raster+y*w, 0, y, w, nrow, fromskew, toskew, buf + pos); - y += ((flip & FLIP_VERTICALLY) ? -(int32) nrow : (int32) nrow); + y += ((flip & FLIP_VERTICALLY) ? -(int32_t) nrow : (int32_t) nrow); } if (flip & FLIP_HORIZONTALLY) { - uint32 line; + uint32_t line; for (line = 0; line < h; line++) { - uint32 *left = raster + (line * w); - uint32 *right = left + w - 1; + uint32_t *left = raster + (line * w); + uint32_t *right = left + w - 1; while ( left < right ) { - uint32 temp = *left; + uint32_t temp = *left; *left = *right; *right = temp; left++; @@ -1027,23 +1027,23 @@ gtStripContig(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h) * We assume that all such images are RGB. */ static int -gtStripSeparate(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h) +gtStripSeparate(TIFFRGBAImage* img, uint32_t* raster, uint32_t w, uint32_t h) { TIFF* tif = img->tif; tileSeparateRoutine put = img->put.separate; unsigned char *buf = NULL; unsigned char *p0 = NULL, *p1 = NULL, *p2 = NULL, *pa = NULL; - uint32 row, y, nrow, rowstoread; + uint32_t row, y, nrow, rowstoread; tmsize_t pos; tmsize_t scanline; - uint32 rowsperstrip, offset_row; - uint32 imagewidth = img->width; + uint32_t rowsperstrip, offset_row; + uint32_t imagewidth = img->width; tmsize_t stripsize; tmsize_t bufsize; - int32 fromskew, toskew; + int32_t fromskew, toskew; int alpha = img->alpha; int ret = 1, flip; - uint16 colorchannels; + uint16_t colorchannels; stripsize = TIFFStripSize(tif); bufsize = _TIFFMultiplySSize(tif,alpha?4:3,stripsize, "gtStripSeparate"); @@ -1058,11 +1058,11 @@ gtStripSeparate(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h) return (0); } y = h - 1; - toskew = -(int32)(w + w); + toskew = -(int32_t)(w + w); } else { y = 0; - toskew = -(int32)(w - w); + toskew = -(int32_t)(w - w); } switch( img->photometric ) @@ -1083,7 +1083,7 @@ gtStripSeparate(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h) fromskew = (w < imagewidth ? imagewidth - w : 0); for (row = 0; row < h; row += nrow) { - uint32 temp; + uint32_t temp; rowstoread = rowsperstrip - (row + img->row_offset) % rowsperstrip; nrow = (row + rowstoread > h ? h - row : rowstoread); offset_row = row + img->row_offset; @@ -1155,18 +1155,18 @@ gtStripSeparate(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h) ((tmsize_t) img->col_offset * img->samplesperpixel); (*put)(img, raster+y*w, 0, y, w, nrow, fromskew, toskew, p0 + pos, p1 + pos, p2 + pos, (alpha?(pa+pos):NULL)); - y += ((flip & FLIP_VERTICALLY) ? -(int32) nrow : (int32) nrow); + y += ((flip & FLIP_VERTICALLY) ? -(int32_t) nrow : (int32_t) nrow); } if (flip & FLIP_HORIZONTALLY) { - uint32 line; + uint32_t line; for (line = 0; line < h; line++) { - uint32 *left = raster + (line * w); - uint32 *right = left + w - 1; + uint32_t *left = raster + (line * w); + uint32_t *right = left + w - 1; while ( left < right ) { - uint32 temp = *left; + uint32_t temp = *left; *left = *right; *right = temp; left++; @@ -1206,7 +1206,7 @@ gtStripSeparate(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h) #define NOP #define UNROLL8(w, op1, op2) { \ - uint32 _x; \ + uint32_t _x; \ for (_x = w; _x >= 8; _x -= 8) { \ op1; \ REPEAT8(op2); \ @@ -1217,7 +1217,7 @@ gtStripSeparate(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h) } \ } #define UNROLL4(w, op1, op2) { \ - uint32 _x; \ + uint32_t _x; \ for (_x = w; _x >= 4; _x -= 4) { \ op1; \ REPEAT4(op2); \ @@ -1228,7 +1228,7 @@ gtStripSeparate(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h) } \ } #define UNROLL2(w, op1, op2) { \ - uint32 _x; \ + uint32_t _x; \ for (_x = w; _x >= 2; _x -= 2) { \ op1; \ REPEAT2(op2); \ @@ -1242,25 +1242,25 @@ gtStripSeparate(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h) #define SKEW(r,g,b,skew) { r += skew; g += skew; b += skew; } #define SKEW4(r,g,b,a,skew) { r += skew; g += skew; b += skew; a+= skew; } -#define A1 (((uint32)0xffL)<<24) +#define A1 (((uint32_t)0xffL)<<24) #define PACK(r,g,b) \ - ((uint32)(r)|((uint32)(g)<<8)|((uint32)(b)<<16)|A1) + ((uint32_t)(r)|((uint32_t)(g)<<8)|((uint32_t)(b)<<16)|A1) #define PACK4(r,g,b,a) \ - ((uint32)(r)|((uint32)(g)<<8)|((uint32)(b)<<16)|((uint32)(a)<<24)) + ((uint32_t)(r)|((uint32_t)(g)<<8)|((uint32_t)(b)<<16)|((uint32_t)(a)<<24)) #define W2B(v) (((v)>>8)&0xff) /* TODO: PACKW should have be made redundant in favor of Bitdepth16To8 LUT */ #define PACKW(r,g,b) \ - ((uint32)W2B(r)|((uint32)W2B(g)<<8)|((uint32)W2B(b)<<16)|A1) + ((uint32_t)W2B(r)|((uint32_t)W2B(g)<<8)|((uint32_t)W2B(b)<<16)|A1) #define PACKW4(r,g,b,a) \ - ((uint32)W2B(r)|((uint32)W2B(g)<<8)|((uint32)W2B(b)<<16)|((uint32)W2B(a)<<24)) + ((uint32_t)W2B(r)|((uint32_t)W2B(g)<<8)|((uint32_t)W2B(b)<<16)|((uint32_t)W2B(a)<<24)) #define DECLAREContigPutFunc(name) \ static void name(\ TIFFRGBAImage* img, \ - uint32* cp, \ - uint32 x, uint32 y, \ - uint32 w, uint32 h, \ - int32 fromskew, int32 toskew, \ + uint32_t* cp, \ + uint32_t x, uint32_t y, \ + uint32_t w, uint32_t h, \ + int32_t fromskew, int32_t toskew, \ unsigned char* pp \ ) @@ -1269,7 +1269,7 @@ static void name(\ */ DECLAREContigPutFunc(put8bitcmaptile) { - uint32** PALmap = img->PALmap; + uint32_t** PALmap = img->PALmap; int samplesperpixel = img->samplesperpixel; (void) y; @@ -1289,12 +1289,12 @@ DECLAREContigPutFunc(put8bitcmaptile) */ DECLAREContigPutFunc(put4bitcmaptile) { - uint32** PALmap = img->PALmap; + uint32_t** PALmap = img->PALmap; (void) x; (void) y; fromskew /= 2; for( ; h > 0; --h) { - uint32* bw; + uint32_t* bw; UNROLL2(w, bw = PALmap[*pp++], *cp++ = *bw++); cp += toskew; pp += fromskew; @@ -1306,12 +1306,12 @@ DECLAREContigPutFunc(put4bitcmaptile) */ DECLAREContigPutFunc(put2bitcmaptile) { - uint32** PALmap = img->PALmap; + uint32_t** PALmap = img->PALmap; (void) x; (void) y; fromskew /= 4; for( ; h > 0; --h) { - uint32* bw; + uint32_t* bw; UNROLL4(w, bw = PALmap[*pp++], *cp++ = *bw++); cp += toskew; pp += fromskew; @@ -1323,12 +1323,12 @@ DECLAREContigPutFunc(put2bitcmaptile) */ DECLAREContigPutFunc(put1bitcmaptile) { - uint32** PALmap = img->PALmap; + uint32_t** PALmap = img->PALmap; (void) x; (void) y; fromskew /= 8; for( ; h > 0; --h) { - uint32* bw; + uint32_t* bw; UNROLL8(w, bw = PALmap[*pp++], *cp++ = *bw++); cp += toskew; pp += fromskew; @@ -1341,7 +1341,7 @@ DECLAREContigPutFunc(put1bitcmaptile) DECLAREContigPutFunc(putgreytile) { int samplesperpixel = img->samplesperpixel; - uint32** BWmap = img->BWmap; + uint32_t** BWmap = img->BWmap; (void) y; for( ; h > 0; --h) { @@ -1361,13 +1361,13 @@ DECLAREContigPutFunc(putgreytile) DECLAREContigPutFunc(putagreytile) { int samplesperpixel = img->samplesperpixel; - uint32** BWmap = img->BWmap; + uint32_t** BWmap = img->BWmap; (void) y; for( ; h > 0; --h) { for (x = w; x > 0; --x) { - *cp++ = BWmap[*pp][0] & ((uint32)*(pp+1) << 24 | ~A1); + *cp++ = BWmap[*pp][0] & ((uint32_t)*(pp + 1) << 24 | ~A1); pp += samplesperpixel; } cp += toskew; @@ -1381,11 +1381,11 @@ DECLAREContigPutFunc(putagreytile) DECLAREContigPutFunc(put16bitbwtile) { int samplesperpixel = img->samplesperpixel; - uint32** BWmap = img->BWmap; + uint32_t** BWmap = img->BWmap; (void) y; for( ; h > 0; --h) { - uint16 *wp = (uint16 *) pp; + uint16_t *wp = (uint16_t *) pp; for (x = w; x > 0; --x) { @@ -1405,12 +1405,12 @@ DECLAREContigPutFunc(put16bitbwtile) */ DECLAREContigPutFunc(put1bitbwtile) { - uint32** BWmap = img->BWmap; + uint32_t** BWmap = img->BWmap; (void) x; (void) y; fromskew /= 8; for( ; h > 0; --h) { - uint32* bw; + uint32_t* bw; UNROLL8(w, bw = BWmap[*pp++], *cp++ = *bw++); cp += toskew; pp += fromskew; @@ -1422,12 +1422,12 @@ DECLAREContigPutFunc(put1bitbwtile) */ DECLAREContigPutFunc(put2bitbwtile) { - uint32** BWmap = img->BWmap; + uint32_t** BWmap = img->BWmap; (void) x; (void) y; fromskew /= 4; for( ; h > 0; --h) { - uint32* bw; + uint32_t* bw; UNROLL4(w, bw = BWmap[*pp++], *cp++ = *bw++); cp += toskew; pp += fromskew; @@ -1439,12 +1439,12 @@ DECLAREContigPutFunc(put2bitbwtile) */ DECLAREContigPutFunc(put4bitbwtile) { - uint32** BWmap = img->BWmap; + uint32_t** BWmap = img->BWmap; (void) x; (void) y; fromskew /= 2; for( ; h > 0; --h) { - uint32* bw; + uint32_t* bw; UNROLL2(w, bw = BWmap[*pp++], *cp++ = *bw++); cp += toskew; pp += fromskew; @@ -1498,8 +1498,8 @@ DECLAREContigPutFunc(putRGBUAcontig8bittile) (void) y; fromskew *= samplesperpixel; for( ; h > 0; --h) { - uint32 r, g, b, a; - uint8* m; + uint32_t r, g, b, a; + uint8_t* m; for (x = w; x > 0; --x) { a = pp[3]; m = img->UaToAa+((size_t) a<<8); @@ -1520,7 +1520,7 @@ DECLAREContigPutFunc(putRGBUAcontig8bittile) DECLAREContigPutFunc(putRGBcontig16bittile) { int samplesperpixel = img->samplesperpixel; - uint16 *wp = (uint16 *)pp; + uint16_t *wp = (uint16_t *)pp; (void) y; fromskew *= samplesperpixel; for( ; h > 0; --h) { @@ -1542,7 +1542,7 @@ DECLAREContigPutFunc(putRGBcontig16bittile) DECLAREContigPutFunc(putRGBAAcontig16bittile) { int samplesperpixel = img->samplesperpixel; - uint16 *wp = (uint16 *)pp; + uint16_t *wp = (uint16_t *)pp; (void) y; fromskew *= samplesperpixel; for( ; h > 0; --h) { @@ -1565,12 +1565,12 @@ DECLAREContigPutFunc(putRGBAAcontig16bittile) DECLAREContigPutFunc(putRGBUAcontig16bittile) { int samplesperpixel = img->samplesperpixel; - uint16 *wp = (uint16 *)pp; + uint16_t *wp = (uint16_t *)pp; (void) y; fromskew *= samplesperpixel; for( ; h > 0; --h) { - uint32 r,g,b,a; - uint8* m; + uint32_t r,g,b,a; + uint8_t* m; for (x = w; x > 0; --x) { a = img->Bitdepth16To8[wp[3]]; m = img->UaToAa+((size_t) a<<8); @@ -1593,7 +1593,7 @@ DECLAREContigPutFunc(putRGBUAcontig16bittile) DECLAREContigPutFunc(putRGBcontig8bitCMYKtile) { int samplesperpixel = img->samplesperpixel; - uint16 r, g, b, k; + uint16_t r, g, b, k; (void) x; (void) y; fromskew *= samplesperpixel; @@ -1619,7 +1619,7 @@ DECLAREContigPutFunc(putRGBcontig8bitCMYKMaptile) { int samplesperpixel = img->samplesperpixel; TIFFRGBValue* Map = img->Map; - uint16 r, g, b, k; + uint16_t r, g, b, k; (void) y; fromskew *= samplesperpixel; @@ -1640,10 +1640,10 @@ DECLAREContigPutFunc(putRGBcontig8bitCMYKMaptile) #define DECLARESepPutFunc(name) \ static void name(\ TIFFRGBAImage* img,\ - uint32* cp,\ - uint32 x, uint32 y, \ - uint32 w, uint32 h,\ - int32 fromskew, int32 toskew,\ + uint32_t* cp,\ + uint32_t x, uint32_t y, \ + uint32_t w, uint32_t h,\ + int32_t fromskew, int32_t toskew,\ unsigned char* r, unsigned char* g, unsigned char* b, unsigned char* a\ ) @@ -1680,7 +1680,7 @@ DECLARESepPutFunc(putCMYKseparate8bittile) { (void) img; (void) y; for( ; h > 0; --h) { - uint32 rv, gv, bv, kv; + uint32_t rv, gv, bv, kv; for (x = w; x > 0; --x) { kv = 255 - *a++; rv = (kv*(255-*r++))/255; @@ -1700,8 +1700,8 @@ DECLARESepPutFunc(putRGBUAseparate8bittile) { (void) img; (void) y; for( ; h > 0; --h) { - uint32 rv, gv, bv, av; - uint8* m; + uint32_t rv, gv, bv, av; + uint8_t* m; for (x = w; x > 0; --x) { av = *a++; m = img->UaToAa+((size_t) av<<8); @@ -1720,9 +1720,9 @@ DECLARESepPutFunc(putRGBUAseparate8bittile) */ DECLARESepPutFunc(putRGBseparate16bittile) { - uint16 *wr = (uint16*) r; - uint16 *wg = (uint16*) g; - uint16 *wb = (uint16*) b; + uint16_t *wr = (uint16_t*) r; + uint16_t *wg = (uint16_t*) g; + uint16_t *wb = (uint16_t*) b; (void) img; (void) y; (void) a; for( ; h > 0; --h) { for (x = 0; x < w; x++) @@ -1739,10 +1739,10 @@ DECLARESepPutFunc(putRGBseparate16bittile) */ DECLARESepPutFunc(putRGBAAseparate16bittile) { - uint16 *wr = (uint16*) r; - uint16 *wg = (uint16*) g; - uint16 *wb = (uint16*) b; - uint16 *wa = (uint16*) a; + uint16_t *wr = (uint16_t*) r; + uint16_t *wg = (uint16_t*) g; + uint16_t *wb = (uint16_t*) b; + uint16_t *wa = (uint16_t*) a; (void) img; (void) y; for( ; h > 0; --h) { for (x = 0; x < w; x++) @@ -1760,14 +1760,14 @@ DECLARESepPutFunc(putRGBAAseparate16bittile) */ DECLARESepPutFunc(putRGBUAseparate16bittile) { - uint16 *wr = (uint16*) r; - uint16 *wg = (uint16*) g; - uint16 *wb = (uint16*) b; - uint16 *wa = (uint16*) a; + uint16_t *wr = (uint16_t*) r; + uint16_t *wg = (uint16_t*) g; + uint16_t *wb = (uint16_t*) b; + uint16_t *wa = (uint16_t*) a; (void) img; (void) y; for( ; h > 0; --h) { - uint32 r2,g2,b2,a2; - uint8* m; + uint32_t r2,g2,b2,a2; + uint8_t* m; for (x = w; x > 0; --x) { a2 = img->Bitdepth16To8[*wa++]; m = img->UaToAa+((size_t) a2<<8); @@ -1787,7 +1787,7 @@ DECLARESepPutFunc(putRGBUAseparate16bittile) DECLAREContigPutFunc(putcontig8bitCIELab) { float X, Y, Z; - uint32 r, g, b; + uint32_t r, g, b; (void) y; fromskew *= 3; for( ; h > 0; --h) { @@ -1811,7 +1811,7 @@ DECLAREContigPutFunc(putcontig8bitCIELab) */ #define YCbCrtoRGB(dst, Y) { \ - uint32 r, g, b; \ + uint32_t r, g, b; \ TIFFYCbCrtoRGB(img->ycbcr, (Y), Cb, Cr, &r, &g, &b); \ dst = PACK(r, g, b); \ } @@ -1827,20 +1827,20 @@ DECLAREContigPutFunc(putcontig8bitCIELab) #ifdef notdef static void putcontig8bitYCbCrGenericTile( TIFFRGBAImage* img, - uint32* cp, - uint32 x, uint32 y, - uint32 w, uint32 h, - int32 fromskew, int32 toskew, + uint32_t* cp, + uint32_t x, uint32_t y, + uint32_t w, uint32_t h, + int32_t fromskew, int32_t toskew, unsigned char* pp, int h_group, int v_group ) { - uint32* cp1 = cp+w+toskew; - uint32* cp2 = cp1+w+toskew; - uint32* cp3 = cp2+w+toskew; - int32 incr = 3*w+4*toskew; - int32 Cb, Cr; + uint32_t* cp1 = cp+w+toskew; + uint32_t* cp2 = cp1+w+toskew; + uint32_t* cp3 = cp2+w+toskew; + int32_t incr = 3*w+4*toskew; + int32_t Cb, Cr; int group_size = v_group * h_group + 2; (void) y; @@ -1897,10 +1897,10 @@ static void putcontig8bitYCbCrGenericTile( */ DECLAREContigPutFunc(putcontig8bitYCbCr44tile) { - uint32* cp1 = cp+w+toskew; - uint32* cp2 = cp1+w+toskew; - uint32* cp3 = cp2+w+toskew; - int32 incr = 3*w+4*toskew; + uint32_t* cp1 = cp + w + toskew; + uint32_t* cp2 = cp1 + w + toskew; + uint32_t* cp3 = cp2 + w + toskew; + int32_t incr = 3 * w + 4 * toskew; (void) y; /* adjust fromskew */ @@ -1909,8 +1909,8 @@ DECLAREContigPutFunc(putcontig8bitYCbCr44tile) for (; h >= 4; h -= 4) { x = w>>2; do { - int32 Cb = pp[16]; - int32 Cr = pp[17]; + int32_t Cb = pp[16]; + int32_t Cr = pp[17]; YCbCrtoRGB(cp [0], pp[ 0]); YCbCrtoRGB(cp [1], pp[ 1]); @@ -1944,8 +1944,8 @@ DECLAREContigPutFunc(putcontig8bitYCbCr44tile) } else { while (h > 0) { for (x = w; x > 0;) { - int32 Cb = pp[16]; - int32 Cr = pp[17]; + int32_t Cb = pp[16]; + int32_t Cr = pp[17]; switch (x) { default: switch (h) { @@ -2003,8 +2003,8 @@ DECLAREContigPutFunc(putcontig8bitYCbCr44tile) */ DECLAREContigPutFunc(putcontig8bitYCbCr42tile) { - uint32* cp1 = cp+w+toskew; - int32 incr = 2*toskew+w; + uint32_t* cp1 = cp + w + toskew; + int32_t incr = 2 * toskew + w; (void) y; fromskew = (fromskew / 4) * (4*2+2); @@ -2012,8 +2012,8 @@ DECLAREContigPutFunc(putcontig8bitYCbCr42tile) for (; h >= 2; h -= 2) { x = w>>2; do { - int32 Cb = pp[8]; - int32 Cr = pp[9]; + int32_t Cb = pp[8]; + int32_t Cr = pp[9]; YCbCrtoRGB(cp [0], pp[0]); YCbCrtoRGB(cp [1], pp[1]); @@ -2035,8 +2035,8 @@ DECLAREContigPutFunc(putcontig8bitYCbCr42tile) } else { while (h > 0) { for (x = w; x > 0;) { - int32 Cb = pp[8]; - int32 Cr = pp[9]; + int32_t Cb = pp[8]; + int32_t Cr = pp[9]; switch (x) { default: switch (h) { @@ -2089,8 +2089,8 @@ DECLAREContigPutFunc(putcontig8bitYCbCr41tile) do { x = w>>2; while(x>0) { - int32 Cb = pp[4]; - int32 Cr = pp[5]; + int32_t Cb = pp[4]; + int32_t Cr = pp[5]; YCbCrtoRGB(cp [0], pp[0]); YCbCrtoRGB(cp [1], pp[1]); @@ -2104,8 +2104,8 @@ DECLAREContigPutFunc(putcontig8bitYCbCr41tile) if( (w&3) != 0 ) { - int32 Cb = pp[4]; - int32 Cr = pp[5]; + int32_t Cb = pp[4]; + int32_t Cr = pp[5]; switch( (w&3) ) { case 3: YCbCrtoRGB(cp [2], pp[2]); /*-fallthrough*/ @@ -2129,16 +2129,16 @@ DECLAREContigPutFunc(putcontig8bitYCbCr41tile) */ DECLAREContigPutFunc(putcontig8bitYCbCr22tile) { - uint32* cp2; - int32 incr = 2*toskew+w; + uint32_t* cp2; + int32_t incr = 2 * toskew + w; (void) y; fromskew = (fromskew / 2) * (2*2+2); cp2 = cp+w+toskew; while (h>=2) { x = w; while (x>=2) { - uint32 Cb = pp[4]; - uint32 Cr = pp[5]; + uint32_t Cb = pp[4]; + uint32_t Cr = pp[5]; YCbCrtoRGB(cp[0], pp[0]); YCbCrtoRGB(cp[1], pp[1]); YCbCrtoRGB(cp2[0], pp[2]); @@ -2149,8 +2149,8 @@ DECLAREContigPutFunc(putcontig8bitYCbCr22tile) x -= 2; } if (x==1) { - uint32 Cb = pp[4]; - uint32 Cr = pp[5]; + uint32_t Cb = pp[4]; + uint32_t Cr = pp[5]; YCbCrtoRGB(cp[0], pp[0]); YCbCrtoRGB(cp2[0], pp[2]); cp ++ ; @@ -2165,8 +2165,8 @@ DECLAREContigPutFunc(putcontig8bitYCbCr22tile) if (h==1) { x = w; while (x>=2) { - uint32 Cb = pp[4]; - uint32 Cr = pp[5]; + uint32_t Cb = pp[4]; + uint32_t Cr = pp[5]; YCbCrtoRGB(cp[0], pp[0]); YCbCrtoRGB(cp[1], pp[1]); cp += 2; @@ -2175,8 +2175,8 @@ DECLAREContigPutFunc(putcontig8bitYCbCr22tile) x -= 2; } if (x==1) { - uint32 Cb = pp[4]; - uint32 Cr = pp[5]; + uint32_t Cb = pp[4]; + uint32_t Cr = pp[5]; YCbCrtoRGB(cp[0], pp[0]); } } @@ -2192,8 +2192,8 @@ DECLAREContigPutFunc(putcontig8bitYCbCr21tile) do { x = w>>1; while(x>0) { - int32 Cb = pp[2]; - int32 Cr = pp[3]; + int32_t Cb = pp[2]; + int32_t Cr = pp[3]; YCbCrtoRGB(cp[0], pp[0]); YCbCrtoRGB(cp[1], pp[1]); @@ -2205,8 +2205,8 @@ DECLAREContigPutFunc(putcontig8bitYCbCr21tile) if( (w&1) != 0 ) { - int32 Cb = pp[2]; - int32 Cr = pp[3]; + int32_t Cb = pp[2]; + int32_t Cr = pp[3]; YCbCrtoRGB(cp[0], pp[0]); @@ -2224,16 +2224,16 @@ DECLAREContigPutFunc(putcontig8bitYCbCr21tile) */ DECLAREContigPutFunc(putcontig8bitYCbCr12tile) { - uint32* cp2; - int32 incr = 2*toskew+w; + uint32_t* cp2; + int32_t incr = 2 * toskew + w; (void) y; fromskew = (fromskew / 1) * (1 * 2 + 2); cp2 = cp+w+toskew; while (h>=2) { x = w; do { - uint32 Cb = pp[2]; - uint32 Cr = pp[3]; + uint32_t Cb = pp[2]; + uint32_t Cr = pp[3]; YCbCrtoRGB(cp[0], pp[0]); YCbCrtoRGB(cp2[0], pp[1]); cp ++; @@ -2248,8 +2248,8 @@ DECLAREContigPutFunc(putcontig8bitYCbCr12tile) if (h==1) { x = w; do { - uint32 Cb = pp[2]; - uint32 Cr = pp[3]; + uint32_t Cb = pp[2]; + uint32_t Cr = pp[3]; YCbCrtoRGB(cp[0], pp[0]); cp ++; pp += 4; @@ -2267,8 +2267,8 @@ DECLAREContigPutFunc(putcontig8bitYCbCr11tile) do { x = w; /* was x = w>>1; patched 2000/09/25 warmerda@home.com */ do { - int32 Cb = pp[1]; - int32 Cr = pp[2]; + int32_t Cb = pp[1]; + int32_t Cr = pp[2]; YCbCrtoRGB(*cp++, pp[0]); @@ -2290,7 +2290,7 @@ DECLARESepPutFunc(putseparate8bitYCbCr11tile) for( ; h > 0; --h) { x = w; do { - uint32 dr, dg, db; + uint32_t dr, dg, db; TIFFYCbCrtoRGB(img->ycbcr,*r++,*g++,*b++,&dr,&dg,&db); *cp++ = PACK(dr,dg,db); } while (--x); @@ -2317,7 +2317,7 @@ initYCbCrConversion(TIFFRGBAImage* img) TIFFroundup_32(sizeof (TIFFYCbCrToRGB), sizeof (long)) + 4*256*sizeof (TIFFRGBValue) + 2*256*sizeof (int) - + 3*256*sizeof (int32) + + 3*256*sizeof (int32_t) ); if (img->ycbcr == NULL) { TIFFErrorExt(img->tif->tif_clientdata, module, @@ -2412,18 +2412,18 @@ makebwmap(TIFFRGBAImage* img) int bitspersample = img->bitspersample; int nsamples = 8 / bitspersample; int i; - uint32* p; + uint32_t* p; if( nsamples == 0 ) nsamples = 1; - img->BWmap = (uint32**) _TIFFmalloc( - 256*sizeof (uint32 *)+(256*nsamples*sizeof(uint32))); + img->BWmap = (uint32_t**) _TIFFmalloc( + 256*sizeof (uint32_t *) + (256 * nsamples * sizeof(uint32_t))); if (img->BWmap == NULL) { TIFFErrorExt(img->tif->tif_clientdata, TIFFFileName(img->tif), "No space for B&W mapping table"); return (0); } - p = (uint32*)(img->BWmap + 256); + p = (uint32_t*)(img->BWmap + 256); for (i = 0; i < 256; i++) { TIFFRGBValue c; img->BWmap[i] = p; @@ -2467,13 +2467,13 @@ makebwmap(TIFFRGBAImage* img) static int setupMap(TIFFRGBAImage* img) { - int32 x, range; + int32_t x, range; - range = (int32)((1L<<img->bitspersample)-1); + range = (int32_t)((1L << img->bitspersample) - 1); /* treat 16 bit the same as eight bit */ if( img->bitspersample == 16 ) - range = (int32) 255; + range = (int32_t) 255; img->Map = (TIFFRGBValue*) _TIFFmalloc((range+1) * sizeof (TIFFRGBValue)); if (img->Map == NULL) { @@ -2507,9 +2507,9 @@ setupMap(TIFFRGBAImage* img) static int checkcmap(TIFFRGBAImage* img) { - uint16* r = img->redcmap; - uint16* g = img->greencmap; - uint16* b = img->bluecmap; + uint16_t* r = img->redcmap; + uint16_t* g = img->greencmap; + uint16_t* b = img->bluecmap; long n = 1L<<img->bitspersample; while (n-- > 0) @@ -2521,13 +2521,13 @@ checkcmap(TIFFRGBAImage* img) static void cvtcmap(TIFFRGBAImage* img) { - uint16* r = img->redcmap; - uint16* g = img->greencmap; - uint16* b = img->bluecmap; + uint16_t* r = img->redcmap; + uint16_t* g = img->greencmap; + uint16_t* b = img->bluecmap; long i; for (i = (1L<<img->bitspersample)-1; i >= 0; i--) { -#define CVT(x) ((uint16)((x)>>8)) +#define CVT(x) ((uint16_t)((x)>>8)) r[i] = CVT(r[i]); g[i] = CVT(g[i]); b[i] = CVT(b[i]); @@ -2547,19 +2547,19 @@ makecmap(TIFFRGBAImage* img) { int bitspersample = img->bitspersample; int nsamples = 8 / bitspersample; - uint16* r = img->redcmap; - uint16* g = img->greencmap; - uint16* b = img->bluecmap; - uint32 *p; + uint16_t* r = img->redcmap; + uint16_t* g = img->greencmap; + uint16_t* b = img->bluecmap; + uint32_t *p; int i; - img->PALmap = (uint32**) _TIFFmalloc( - 256*sizeof (uint32 *)+(256*nsamples*sizeof(uint32))); + img->PALmap = (uint32_t**) _TIFFmalloc( + 256*sizeof (uint32_t *) + (256 * nsamples * sizeof(uint32_t))); if (img->PALmap == NULL) { TIFFErrorExt(img->tif->tif_clientdata, TIFFFileName(img->tif), "No space for Palette mapping table"); return (0); } - p = (uint32*)(img->PALmap + 256); + p = (uint32_t*)(img->PALmap + 256); for (i = 0; i < 256; i++) { TIFFRGBValue c; img->PALmap[i] = p; @@ -2746,8 +2746,8 @@ PickContigCase(TIFFRGBAImage* img) * Joris: added support for the [1,2] case, nonetheless, to accommodate * some OJPEG files */ - uint16 SubsamplingHor; - uint16 SubsamplingVer; + uint16_t SubsamplingHor; + uint16_t SubsamplingVer; TIFFGetFieldDefaulted(img->tif, TIFFTAG_YCBCRSUBSAMPLING, &SubsamplingHor, &SubsamplingVer); switch ((SubsamplingHor<<4)|SubsamplingVer) { case 0x44: @@ -2845,7 +2845,7 @@ PickSeparateCase(TIFFRGBAImage* img) { if (initYCbCrConversion(img)!=0) { - uint16 hs, vs; + uint16_t hs, vs; TIFFGetFieldDefaulted(img->tif, TIFFTAG_YCBCRSUBSAMPLING, &hs, &vs); switch ((hs<<4)|vs) { case 0x11: @@ -2864,8 +2864,8 @@ static int BuildMapUaToAa(TIFFRGBAImage* img) { static const char module[]="BuildMapUaToAa"; - uint8* m; - uint16 na,nv; + uint8_t* m; + uint16_t na,nv; assert(img->UaToAa==NULL); img->UaToAa=_TIFFmalloc(65536); if (img->UaToAa==NULL) @@ -2877,7 +2877,7 @@ BuildMapUaToAa(TIFFRGBAImage* img) for (na=0; na<256; na++) { for (nv=0; nv<256; nv++) - *m++=(uint8)((nv*na+127)/255); + *m++=(uint8_t)((nv * na + 127) / 255); } return(1); } @@ -2886,8 +2886,8 @@ static int BuildMapBitdepth16To8(TIFFRGBAImage* img) { static const char module[]="BuildMapBitdepth16To8"; - uint8* m; - uint32 n; + uint8_t* m; + uint32_t n; assert(img->Bitdepth16To8==NULL); img->Bitdepth16To8=_TIFFmalloc(65536); if (img->Bitdepth16To8==NULL) @@ -2897,7 +2897,7 @@ BuildMapBitdepth16To8(TIFFRGBAImage* img) } m=img->Bitdepth16To8; for (n=0; n<65536; n++) - *m++=(uint8)((n+128)/257); + *m++=(uint8_t)((n + 128) / 257); return(1); } @@ -2911,20 +2911,20 @@ BuildMapBitdepth16To8(TIFFRGBAImage* img) int -TIFFReadRGBAStrip(TIFF* tif, uint32 row, uint32 * raster ) +TIFFReadRGBAStrip(TIFF* tif, uint32_t row, uint32_t * raster ) { return TIFFReadRGBAStripExt(tif, row, raster, 0 ); } int -TIFFReadRGBAStripExt(TIFF* tif, uint32 row, uint32 * raster, int stop_on_error) +TIFFReadRGBAStripExt(TIFF* tif, uint32_t row, uint32_t * raster, int stop_on_error) { char emsg[1024] = ""; TIFFRGBAImage img; int ok; - uint32 rowsperstrip, rows_to_read; + uint32_t rowsperstrip, rows_to_read; if( TIFFIsTiled( tif ) ) { @@ -2969,7 +2969,7 @@ TIFFReadRGBAStripExt(TIFF* tif, uint32 row, uint32 * raster, int stop_on_error) */ int -TIFFReadRGBATile(TIFF* tif, uint32 col, uint32 row, uint32 * raster) +TIFFReadRGBATile(TIFF* tif, uint32_t col, uint32_t row, uint32_t * raster) { return TIFFReadRGBATileExt(tif, col, row, raster, 0 ); @@ -2977,14 +2977,14 @@ TIFFReadRGBATile(TIFF* tif, uint32 col, uint32 row, uint32 * raster) int -TIFFReadRGBATileExt(TIFF* tif, uint32 col, uint32 row, uint32 * raster, int stop_on_error ) +TIFFReadRGBATileExt(TIFF* tif, uint32_t col, uint32_t row, uint32_t * raster, int stop_on_error ) { char emsg[1024] = ""; TIFFRGBAImage img; int ok; - uint32 tile_xsize, tile_ysize; - uint32 read_xsize, read_ysize; - uint32 i_row; + uint32_t tile_xsize, tile_ysize; + uint32_t read_xsize, read_ysize; + uint32_t i_row; /* * Verify that our request is legal - on a tile file, and on a @@ -3060,14 +3060,14 @@ TIFFReadRGBATileExt(TIFF* tif, uint32 col, uint32 row, uint32 * raster, int stop for( i_row = 0; i_row < read_ysize; i_row++ ) { memmove( raster + (tile_ysize - i_row - 1) * tile_xsize, raster + (read_ysize - i_row - 1) * read_xsize, - read_xsize * sizeof(uint32) ); + read_xsize * sizeof(uint32_t) ); _TIFFmemset( raster + (tile_ysize - i_row - 1) * tile_xsize+read_xsize, - 0, sizeof(uint32) * (tile_xsize - read_xsize) ); + 0, sizeof(uint32_t) * (tile_xsize - read_xsize) ); } for( i_row = read_ysize; i_row < tile_ysize; i_row++ ) { _TIFFmemset( raster + (tile_ysize - i_row - 1) * tile_xsize, - 0, sizeof(uint32) * tile_xsize ); + 0, sizeof(uint32_t) * tile_xsize ); } return (ok); diff --git a/tiff/libtiff/tif_jbig.c b/tiff/libtiff/tif_jbig.c index a3500e0b..74086338 100644 --- a/tiff/libtiff/tif_jbig.c +++ b/tiff/libtiff/tif_jbig.c @@ -46,7 +46,7 @@ static int JBIGSetupDecode(TIFF* tif) return 1; } -static int JBIGDecode(TIFF* tif, uint8* buffer, tmsize_t size, uint16 s) +static int JBIGDecode(TIFF* tif, uint8_t* buffer, tmsize_t size, uint16_t s) { struct jbg_dec_state decoder; int decodeStatus = 0; @@ -101,14 +101,14 @@ static int JBIGDecode(TIFF* tif, uint8* buffer, tmsize_t size, uint16 s) if( (tmsize_t)decodedSize < size ) { TIFFWarningExt(tif->tif_clientdata, "JBIG", - "Only decoded %lu bytes, whereas %lu requested", - decodedSize, (unsigned long)size); + "Only decoded %lu bytes, whereas %"TIFF_SSIZE_FORMAT" requested", + decodedSize, size); } else if( (tmsize_t)decodedSize > size ) { TIFFErrorExt(tif->tif_clientdata, "JBIG", - "Decoded %lu bytes, whereas %lu were requested", - decodedSize, (unsigned long)size); + "Decoded %lu bytes, whereas %"TIFF_SSIZE_FORMAT" were requested", + decodedSize, size); jbg_dec_free(&decoder); return 0; } @@ -133,7 +133,7 @@ static int JBIGSetupEncode(TIFF* tif) return 1; } -static int JBIGCopyEncodedData(TIFF* tif, unsigned char* pp, size_t cc, uint16 s) +static int JBIGCopyEncodedData(TIFF* tif, unsigned char* pp, size_t cc, uint16_t s) { (void) s; while (cc > 0) @@ -173,7 +173,7 @@ static void JBIGOutputBie(unsigned char* buffer, size_t len, void* userData) JBIGCopyEncodedData(tif, buffer, len, 0); } -static int JBIGEncode(TIFF* tif, uint8* buffer, tmsize_t size, uint16 s) +static int JBIGEncode(TIFF* tif, uint8_t* buffer, tmsize_t size, uint16_t s) { TIFFDirectory* dir = &tif->tif_dir; struct jbg_enc_state encoder; diff --git a/tiff/libtiff/tif_jpeg.c b/tiff/libtiff/tif_jpeg.c index d051471e..73265808 100644 --- a/tiff/libtiff/tif_jpeg.c +++ b/tiff/libtiff/tif_jpeg.c @@ -44,8 +44,8 @@ */ #include <setjmp.h> -int TIFFFillStrip(TIFF* tif, uint32 strip); -int TIFFFillTile(TIFF* tif, uint32 tile); +int TIFFFillStrip(TIFF* tif, uint32_t strip); +int TIFFFillTile(TIFF* tif, uint32_t tile); int TIFFReInitJPEG_12( TIFF *tif, int scheme, int is_encode ); int TIFFJPEGIsFullStripRequired_12(TIFF* tif); @@ -161,9 +161,9 @@ typedef struct { jpeg_source_mgr src; /* data source for decompression */ /* private state */ TIFF* tif; /* back link needed by some code */ - uint16 photometric; /* copy of PhotometricInterpretation */ - uint16 h_sampling; /* luminance sampling factors */ - uint16 v_sampling; + uint16_t photometric; /* copy of PhotometricInterpretation */ + uint16_t h_sampling; /* luminance sampling factors */ + uint16_t v_sampling; tmsize_t bytesperline; /* decompressed bytes per scanline */ /* pointers to intermediate buffers when processing downsampled data */ JSAMPARRAY ds_buffer[MAX_COMPONENTS]; @@ -177,7 +177,7 @@ typedef struct { TIFFTileMethod deftparent; /* super-class method */ /* pseudo-tag fields */ void* jpegtables; /* JPEGTables tag value, or NULL */ - uint32 jpegtables_length; /* number of bytes in same */ + uint32_t jpegtables_length; /* number of bytes in same */ int jpegquality; /* Compression quality level */ int jpegcolormode; /* Auto RGB<=>YCbCr convert? */ int jpegtablesmode; /* What to put in JPEGTables */ @@ -188,12 +188,12 @@ typedef struct { #define JState(tif) ((JPEGState*)(tif)->tif_data) -static int JPEGDecode(TIFF* tif, uint8* buf, tmsize_t cc, uint16 s); -static int JPEGDecodeRaw(TIFF* tif, uint8* buf, tmsize_t cc, uint16 s); -static int JPEGEncode(TIFF* tif, uint8* buf, tmsize_t cc, uint16 s); -static int JPEGEncodeRaw(TIFF* tif, uint8* buf, tmsize_t cc, uint16 s); +static int JPEGDecode(TIFF* tif, uint8_t* buf, tmsize_t cc, uint16_t s); +static int JPEGDecodeRaw(TIFF* tif, uint8_t* buf, tmsize_t cc, uint16_t s); +static int JPEGEncode(TIFF* tif, uint8_t* buf, tmsize_t cc, uint16_t s); +static int JPEGEncodeRaw(TIFF* tif, uint8_t* buf, tmsize_t cc, uint16_t s); static int JPEGInitializeLibJPEG(TIFF * tif, int decode ); -static int DecodeRowError(TIFF* tif, uint8* buf, tmsize_t cc, uint16 s); +static int DecodeRowError(TIFF* tif, uint8_t* buf, tmsize_t cc, uint16_t s); #define FIELD_JPEGTABLES (FIELD_CODEC+0) @@ -489,7 +489,7 @@ std_term_destination(j_compress_ptr cinfo) JPEGState* sp = (JPEGState*) cinfo; TIFF* tif = sp->tif; - tif->tif_rawcp = (uint8*) sp->dest.next_output_byte; + tif->tif_rawcp = (uint8_t*) sp->dest.next_output_byte; tif->tif_rawcc = tif->tif_rawdatasize - (tmsize_t) sp->dest.free_in_buffer; /* NB: libtiff does the final buffer flush */ @@ -543,7 +543,7 @@ tables_term_destination(j_compress_ptr cinfo) JPEGState* sp = (JPEGState*) cinfo; /* set tables length to number of bytes actually emitted */ - sp->jpegtables_length -= (uint32) sp->dest.free_in_buffer; + sp->jpegtables_length -= (uint32_t) sp->dest.free_in_buffer; } static int @@ -733,18 +733,18 @@ struct JPEGFixupTagsSubsamplingData { TIFF* tif; void* buffer; - uint32 buffersize; - uint8* buffercurrentbyte; - uint32 bufferbytesleft; - uint64 fileoffset; - uint64 filebytesleft; - uint8 filepositioned; + uint32_t buffersize; + uint8_t* buffercurrentbyte; + uint32_t bufferbytesleft; + uint64_t fileoffset; + uint64_t filebytesleft; + uint8_t filepositioned; }; static void JPEGFixupTagsSubsampling(TIFF* tif); static int JPEGFixupTagsSubsamplingSec(struct JPEGFixupTagsSubsamplingData* data); -static int JPEGFixupTagsSubsamplingReadByte(struct JPEGFixupTagsSubsamplingData* data, uint8* result); -static int JPEGFixupTagsSubsamplingReadWord(struct JPEGFixupTagsSubsamplingData* data, uint16* result); -static void JPEGFixupTagsSubsamplingSkip(struct JPEGFixupTagsSubsamplingData* data, uint16 skiplength); +static int JPEGFixupTagsSubsamplingReadByte(struct JPEGFixupTagsSubsamplingData* data, uint8_t* result); +static int JPEGFixupTagsSubsamplingReadWord(struct JPEGFixupTagsSubsamplingData* data, uint16_t* result); +static void JPEGFixupTagsSubsamplingSkip(struct JPEGFixupTagsSubsamplingData* data, uint16_t skiplength); #endif @@ -790,7 +790,7 @@ JPEGFixupTagsSubsampling(TIFF* tif) */ static const char module[] = "JPEGFixupTagsSubsampling"; struct JPEGFixupTagsSubsamplingData m; - uint64 fileoffset = TIFFGetStrileOffset(tif, 0); + uint64_t fileoffset = TIFFGetStrileOffset(tif, 0); if( fileoffset == 0 ) { @@ -824,7 +824,7 @@ static int JPEGFixupTagsSubsamplingSec(struct JPEGFixupTagsSubsamplingData* data) { static const char module[] = "JPEGFixupTagsSubsamplingSec"; - uint8 m; + uint8_t m; while (1) { while (1) @@ -869,7 +869,7 @@ JPEGFixupTagsSubsamplingSec(struct JPEGFixupTagsSubsamplingData* data) case JPEG_MARKER_DRI: /* this type of marker has data, but it has no use to us and should be skipped */ { - uint16 n; + uint16_t n; if (!JPEGFixupTagsSubsamplingReadWord(data,&n)) return(0); if (n<2) @@ -886,10 +886,10 @@ JPEGFixupTagsSubsamplingSec(struct JPEGFixupTagsSubsamplingData* data) case JPEG_MARKER_SOF10: /* Progressive arithmetic: normally not allowed by TechNote, but that doesn't hurt supporting it */ /* this marker contains the subsampling factors we're scanning for */ { - uint16 n; - uint16 o; - uint8 p; - uint8 ph,pv; + uint16_t n; + uint16_t o; + uint8_t p; + uint8_t ph,pv; if (!JPEGFixupTagsSubsamplingReadWord(data,&n)) return(0); if (n!=8+data->tif->tif_dir.td_samplesperpixel*3) @@ -922,10 +922,10 @@ JPEGFixupTagsSubsamplingSec(struct JPEGFixupTagsSubsamplingData* data) if ((ph!=data->tif->tif_dir.td_ycbcrsubsampling[0])||(pv!=data->tif->tif_dir.td_ycbcrsubsampling[1])) { TIFFWarningExt(data->tif->tif_clientdata,module, - "Auto-corrected former TIFF subsampling values [%d,%d] to match subsampling values inside JPEG compressed data [%d,%d]", - (int)data->tif->tif_dir.td_ycbcrsubsampling[0], - (int)data->tif->tif_dir.td_ycbcrsubsampling[1], - (int)ph,(int)pv); + "Auto-corrected former TIFF subsampling values [%"PRIu16",%"PRIu16"] to match subsampling values inside JPEG compressed data [%"PRIu8",%"PRIu8"]", + data->tif->tif_dir.td_ycbcrsubsampling[0], + data->tif->tif_dir.td_ycbcrsubsampling[1], + ph, pv); data->tif->tif_dir.td_ycbcrsubsampling[0]=ph; data->tif->tif_dir.td_ycbcrsubsampling[1]=pv; } @@ -938,11 +938,11 @@ JPEGFixupTagsSubsamplingSec(struct JPEGFixupTagsSubsamplingData* data) } static int -JPEGFixupTagsSubsamplingReadByte(struct JPEGFixupTagsSubsamplingData* data, uint8* result) +JPEGFixupTagsSubsamplingReadByte(struct JPEGFixupTagsSubsamplingData* data, uint8_t* result) { if (data->bufferbytesleft==0) { - uint32 m; + uint32_t m; if (data->filebytesleft==0) return(0); if (!data->filepositioned) @@ -954,8 +954,8 @@ JPEGFixupTagsSubsamplingReadByte(struct JPEGFixupTagsSubsamplingData* data, uint data->filepositioned=1; } m=data->buffersize; - if ((uint64)m>data->filebytesleft) - m=(uint32)data->filebytesleft; + if ((uint64_t)m > data->filebytesleft) + m=(uint32_t)data->filebytesleft; assert(m<0x80000000UL); if (TIFFReadFile(data->tif,data->buffer,(tmsize_t)m)!=(tmsize_t)m) return(0); @@ -971,10 +971,10 @@ JPEGFixupTagsSubsamplingReadByte(struct JPEGFixupTagsSubsamplingData* data, uint } static int -JPEGFixupTagsSubsamplingReadWord(struct JPEGFixupTagsSubsamplingData* data, uint16* result) +JPEGFixupTagsSubsamplingReadWord(struct JPEGFixupTagsSubsamplingData* data, uint16_t* result) { - uint8 ma; - uint8 mb; + uint8_t ma; + uint8_t mb; if (!JPEGFixupTagsSubsamplingReadByte(data,&ma)) return(0); if (!JPEGFixupTagsSubsamplingReadByte(data,&mb)) @@ -984,17 +984,17 @@ JPEGFixupTagsSubsamplingReadWord(struct JPEGFixupTagsSubsamplingData* data, uint } static void -JPEGFixupTagsSubsamplingSkip(struct JPEGFixupTagsSubsamplingData* data, uint16 skiplength) +JPEGFixupTagsSubsamplingSkip(struct JPEGFixupTagsSubsamplingData* data, uint16_t skiplength) { - if ((uint32)skiplength<=data->bufferbytesleft) + if ((uint32_t)skiplength <= data->bufferbytesleft) { data->buffercurrentbyte+=skiplength; data->bufferbytesleft-=skiplength; } else { - uint16 m; - m=(uint16)(skiplength-data->bufferbytesleft); + uint16_t m; + m=(uint16_t)(skiplength - data->bufferbytesleft); if (m<=data->filebytesleft) { data->bufferbytesleft=0; @@ -1098,12 +1098,12 @@ int TIFFJPEGIsFullStripRequired(TIFF* tif) * Set up for decoding a strip or tile. */ /*ARGSUSED*/ static int -JPEGPreDecode(TIFF* tif, uint16 s) +JPEGPreDecode(TIFF* tif, uint16_t s) { JPEGState *sp = JState(tif); TIFFDirectory *td = &tif->tif_dir; static const char module[] = "JPEGPreDecode"; - uint32 segment_width, segment_height; + uint32_t segment_width, segment_height; int downsampled_output; int ci; @@ -1128,7 +1128,7 @@ JPEGPreDecode(TIFF* tif, uint16 s) if (TIFFjpeg_read_header(sp, TRUE) != JPEG_HEADER_OK) return (0); - tif->tif_rawcp = (uint8*) sp->src.next_input_byte; + tif->tif_rawcp = (uint8_t*) sp->src.next_input_byte; tif->tif_rawcc = sp->src.bytes_in_buffer; /* @@ -1157,7 +1157,7 @@ JPEGPreDecode(TIFF* tif, uint16 s) sp->cinfo.d.image_height < segment_height) { TIFFWarningExt(tif->tif_clientdata, module, "Improper JPEG strip/tile size, " - "expected %dx%d, got %dx%d", + "expected %"PRIu32"x%"PRIu32", got %ux%u", segment_width, segment_height, sp->cinfo.d.image_width, sp->cinfo.d.image_height); @@ -1172,7 +1172,7 @@ JPEGPreDecode(TIFF* tif, uint16 s) /* we can safely recover from that. */ TIFFWarningExt(tif->tif_clientdata, module, "JPEG strip size exceeds expected dimensions," - " expected %dx%d, got %dx%d", + " expected %"PRIu32"x%"PRIu32", got %ux%u", segment_width, segment_height, sp->cinfo.d.image_width, sp->cinfo.d.image_height); } @@ -1186,7 +1186,7 @@ JPEGPreDecode(TIFF* tif, uint16 s) */ TIFFErrorExt(tif->tif_clientdata, module, "JPEG strip/tile size exceeds expected dimensions," - " expected %dx%d, got %dx%d", + " expected %"PRIu32"x%"PRIu32", got %ux%u", segment_width, segment_height, sp->cinfo.d.image_width, sp->cinfo.d.image_height); return (0); @@ -1240,15 +1240,15 @@ JPEGPreDecode(TIFF* tif, uint16 s) { TIFFErrorExt(tif->tif_clientdata, module, "Reading this image would require libjpeg to allocate " - "at least %u bytes. " - "This is disabled since above the %u threshold. " + "at least %"PRIu64" bytes. " + "This is disabled since above the %ld threshold. " "You may override this restriction by defining the " "LIBTIFF_ALLOW_LARGE_LIBJPEG_MEM_ALLOC environment variable, " "or setting the JPEGMEM environment variable to a value greater " - "or equal to '%uM'", - (unsigned)(nRequiredMemory), - (unsigned)(sp->cinfo.d.mem->max_memory_to_use), - (unsigned)((nRequiredMemory + 1000000 - 1) / 1000000)); + "or equal to '%"PRIu64"M'", + nRequiredMemory, + sp->cinfo.d.mem->max_memory_to_use, + (nRequiredMemory + 1000000u - 1u) / 1000000u); return 0; } } @@ -1259,7 +1259,7 @@ JPEGPreDecode(TIFF* tif, uint16 s) sp->cinfo.d.comp_info[0].v_samp_factor != sp->v_sampling) { TIFFErrorExt(tif->tif_clientdata, module, "Improper JPEG sampling factors %d,%d\n" - "Apparently should be %d,%d.", + "Apparently should be %"PRIu16",%"PRIu16".", sp->cinfo.d.comp_info[0].h_samp_factor, sp->cinfo.d.comp_info[0].v_samp_factor, sp->h_sampling, sp->v_sampling); @@ -1332,7 +1332,7 @@ JPEGPreDecode(TIFF* tif, uint16 s) */ #if !JPEG_LIB_MK1_OR_12BIT static int -JPEGDecode(TIFF* tif, uint8* buf, tmsize_t cc, uint16 s) +JPEGDecode(TIFF* tif, uint8_t* buf, tmsize_t cc, uint16_t s) { JPEGState *sp = JState(tif); tmsize_t nrows; @@ -1377,7 +1377,7 @@ JPEGDecode(TIFF* tif, uint8* buf, tmsize_t cc, uint16 s) } /* Update information on consumed data */ - tif->tif_rawcp = (uint8*) sp->src.next_input_byte; + tif->tif_rawcp = (uint8_t*) sp->src.next_input_byte; tif->tif_rawcc = sp->src.bytes_in_buffer; /* Close down the decompressor if we've finished the strip or tile. */ @@ -1388,7 +1388,7 @@ JPEGDecode(TIFF* tif, uint8* buf, tmsize_t cc, uint16 s) #if JPEG_LIB_MK1_OR_12BIT /*ARGSUSED*/ static int -JPEGDecode(TIFF* tif, uint8* buf, tmsize_t cc, uint16 s) +JPEGDecode(TIFF* tif, uint8_t* buf, tmsize_t cc, uint16_t s) { JPEGState *sp = JState(tif); tmsize_t nrows; @@ -1483,7 +1483,7 @@ JPEGDecode(TIFF* tif, uint8* buf, tmsize_t cc, uint16 s) } /* Update information on consumed data */ - tif->tif_rawcp = (uint8*) sp->src.next_input_byte; + tif->tif_rawcp = (uint8_t*) sp->src.next_input_byte; tif->tif_rawcc = sp->src.bytes_in_buffer; /* Close down the decompressor if we've finished the strip or tile. */ @@ -1493,7 +1493,7 @@ JPEGDecode(TIFF* tif, uint8* buf, tmsize_t cc, uint16 s) #endif /* JPEG_LIB_MK1_OR_12BIT */ /*ARGSUSED*/ static int -DecodeRowError(TIFF* tif, uint8* buf, tmsize_t cc, uint16 s) +DecodeRowError(TIFF* tif, uint8_t* buf, tmsize_t cc, uint16_t s) { (void) buf; @@ -1510,7 +1510,7 @@ DecodeRowError(TIFF* tif, uint8* buf, tmsize_t cc, uint16 s) * Returned data is downsampled per sampling factors. */ /*ARGSUSED*/ static int -JPEGDecodeRaw(TIFF* tif, uint8* buf, tmsize_t cc, uint16 s) +JPEGDecodeRaw(TIFF* tif, uint8_t* buf, tmsize_t cc, uint16_t s) { JPEGState *sp = JState(tif); tmsize_t nrows; @@ -1521,7 +1521,7 @@ JPEGDecodeRaw(TIFF* tif, uint8* buf, tmsize_t cc, uint16 s) /* For last strip, limit number of rows to its truncated height */ /* even if the codestream height is larger (which is not compliant, */ /* but that we tolerate) */ - if( (uint32)nrows > td->td_imagelength - tif->tif_row && !isTiled(tif) ) + if((uint32_t)nrows > td->td_imagelength - tif->tif_row && !isTiled(tif) ) nrows = td->td_imagelength - tif->tif_row; /* data is expected to be read in multiples of a scanline */ @@ -1793,7 +1793,7 @@ JPEGSetupEncode(TIFF* tif) if( td->td_bitspersample > 16 ) { TIFFErrorExt(tif->tif_clientdata, module, - "BitsPerSample %d not allowed for JPEG", + "BitsPerSample %"PRIu16" not allowed for JPEG", td->td_bitspersample); return (0); } @@ -1823,8 +1823,8 @@ JPEGSetupEncode(TIFF* tif) case PHOTOMETRIC_PALETTE: /* disallowed by Tech Note */ case PHOTOMETRIC_MASK: TIFFErrorExt(tif->tif_clientdata, module, - "PhotometricInterpretation %d not allowed for JPEG", - (int) sp->photometric); + "PhotometricInterpretation %"PRIu16" not allowed for JPEG", + sp->photometric); return (0); default: /* TIFF 6.0 forbids subsampling of all other color spaces */ @@ -1847,8 +1847,8 @@ JPEGSetupEncode(TIFF* tif) if (td->td_bitspersample != BITS_IN_JSAMPLE ) #endif { - TIFFErrorExt(tif->tif_clientdata, module, "BitsPerSample %d not allowed for JPEG", - (int) td->td_bitspersample); + TIFFErrorExt(tif->tif_clientdata, module, "BitsPerSample %"PRIu16" not allowed for JPEG", + td->td_bitspersample); return (0); } sp->cinfo.c.data_precision = td->td_bitspersample; @@ -1858,22 +1858,22 @@ JPEGSetupEncode(TIFF* tif) if (isTiled(tif)) { if ((td->td_tilelength % (sp->v_sampling * DCTSIZE)) != 0) { TIFFErrorExt(tif->tif_clientdata, module, - "JPEG tile height must be multiple of %d", - sp->v_sampling * DCTSIZE); + "JPEG tile height must be multiple of %"PRIu32, + (uint32_t)(sp->v_sampling * DCTSIZE)); return (0); } if ((td->td_tilewidth % (sp->h_sampling * DCTSIZE)) != 0) { TIFFErrorExt(tif->tif_clientdata, module, - "JPEG tile width must be multiple of %d", - sp->h_sampling * DCTSIZE); + "JPEG tile width must be multiple of %"PRIu32, + (uint32_t)(sp->h_sampling * DCTSIZE)); return (0); } } else { if (td->td_rowsperstrip < td->td_imagelength && (td->td_rowsperstrip % (sp->v_sampling * DCTSIZE)) != 0) { TIFFErrorExt(tif->tif_clientdata, module, - "RowsPerStrip must be multiple of %d for JPEG", - sp->v_sampling * DCTSIZE); + "RowsPerStrip must be multiple of %"PRIu32" for JPEG", + (uint32_t)(sp->v_sampling * DCTSIZE)); return (0); } } @@ -1906,12 +1906,12 @@ JPEGSetupEncode(TIFF* tif) * Set encoding state at the start of a strip or tile. */ static int -JPEGPreEncode(TIFF* tif, uint16 s) +JPEGPreEncode(TIFF* tif, uint16_t s) { JPEGState *sp = JState(tif); TIFFDirectory *td = &tif->tif_dir; static const char module[] = "JPEGPreEncode"; - uint32 segment_width, segment_height; + uint32_t segment_width, segment_height; int downsampled_input; assert(sp != NULL); @@ -2043,7 +2043,7 @@ JPEGPreEncode(TIFF* tif, uint16 s) * "Standard" case: incoming data is not downsampled. */ static int -JPEGEncode(TIFF* tif, uint8* buf, tmsize_t cc, uint16 s) +JPEGEncode(TIFF* tif, uint8_t* buf, tmsize_t cc, uint16_t s) { JPEGState *sp = JState(tif); tmsize_t nrows; @@ -2121,7 +2121,7 @@ JPEGEncode(TIFF* tif, uint8* buf, tmsize_t cc, uint16 s) * Incoming data is expected to be downsampled per sampling factors. */ static int -JPEGEncodeRaw(TIFF* tif, uint8* buf, tmsize_t cc, uint16 s) +JPEGEncodeRaw(TIFF* tif, uint8_t* buf, tmsize_t cc, uint16_t s) { JPEGState *sp = JState(tif); JSAMPLE* inptr; @@ -2295,17 +2295,17 @@ JPEGResetUpsampled( TIFF* tif ) } static int -JPEGVSetField(TIFF* tif, uint32 tag, va_list ap) +JPEGVSetField(TIFF* tif, uint32_t tag, va_list ap) { JPEGState* sp = JState(tif); const TIFFField* fip; - uint32 v32; + uint32_t v32; assert(sp != NULL); switch (tag) { case TIFFTAG_JPEGTABLES: - v32 = (uint32) va_arg(ap, uint32); + v32 = (uint32_t) va_arg(ap, uint32_t); if (v32 == 0) { /* XXX */ return (0); @@ -2350,7 +2350,7 @@ JPEGVSetField(TIFF* tif, uint32 tag, va_list ap) } static int -JPEGVGetField(TIFF* tif, uint32 tag, va_list ap) +JPEGVGetField(TIFF* tif, uint32_t tag, va_list ap) { JPEGState* sp = JState(tif); @@ -2358,7 +2358,7 @@ JPEGVGetField(TIFF* tif, uint32 tag, va_list ap) switch (tag) { case TIFFTAG_JPEGTABLES: - *va_arg(ap, uint32*) = sp->jpegtables_length; + *va_arg(ap, uint32_t*) = sp->jpegtables_length; *va_arg(ap, const void**) = sp->jpegtables; break; case TIFFTAG_JPEGQUALITY: @@ -2386,15 +2386,15 @@ JPEGPrintDir(TIFF* tif, FILE* fd, long flags) if( sp != NULL ) { if (TIFFFieldSet(tif,FIELD_JPEGTABLES)) - fprintf(fd, " JPEG Tables: (%lu bytes)\n", - (unsigned long) sp->jpegtables_length); + fprintf(fd, " JPEG Tables: (%"PRIu32" bytes)\n", + sp->jpegtables_length); if (sp->printdir) (*sp->printdir)(tif, fd, flags); } } -static uint32 -JPEGDefaultStripSize(TIFF* tif, uint32 s) +static uint32_t +JPEGDefaultStripSize(TIFF* tif, uint32_t s) { JPEGState* sp = JState(tif); TIFFDirectory *td = &tif->tif_dir; @@ -2406,7 +2406,7 @@ JPEGDefaultStripSize(TIFF* tif, uint32 s) } static void -JPEGDefaultTileSize(TIFF* tif, uint32* tw, uint32* th) +JPEGDefaultTileSize(TIFF* tif, uint32_t* tw, uint32_t* th) { JPEGState* sp = JState(tif); TIFFDirectory *td = &tif->tif_dir; @@ -2510,7 +2510,7 @@ TIFFInitJPEG(TIFF* tif, int scheme) /* * Allocate state block so tag methods have storage to record values. */ - tif->tif_data = (uint8*) _TIFFmalloc(sizeof (JPEGState)); + tif->tif_data = (uint8_t*) _TIFFmalloc(sizeof (JPEGState)); if (tif->tif_data == NULL) { TIFFErrorExt(tif->tif_clientdata, diff --git a/tiff/libtiff/tif_lerc.c b/tiff/libtiff/tif_lerc.c new file mode 100644 index 00000000..a4aeb4a1 --- /dev/null +++ b/tiff/libtiff/tif_lerc.c @@ -0,0 +1,1277 @@ +/* +* Copyright (c) 2018, Even Rouault +* Author: <even.rouault at spatialys.com> +* +* 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. +*/ + +#include "tiffiop.h" +#ifdef LERC_SUPPORT +/* +* TIFF Library. +* +* LERC Compression Support +* +*/ + +#include "Lerc_c_api.h" +#include "zlib.h" +#ifdef ZSTD_SUPPORT +#include "zstd.h" +#endif + +#if LIBDEFLATE_SUPPORT +#include "libdeflate.h" +#endif +#define LIBDEFLATE_MAX_COMPRESSION_LEVEL 12 + +#include <assert.h> + +#define LSTATE_INIT_DECODE 0x01 +#define LSTATE_INIT_ENCODE 0x02 + +#ifndef LERC_AT_LEAST_VERSION +#define LERC_AT_LEAST_VERSION(maj,min,patch) 0 +#endif + +/* +* State block for each open TIFF file using LERC compression/decompression. +*/ +typedef struct { + double maxzerror; /* max z error */ + int lerc_version; + int additional_compression; + int zstd_compress_level; /* zstd */ + int zipquality; /* deflate */ + int state; /* state flags */ + + uint32_t segment_width; + uint32_t segment_height; + + unsigned int uncompressed_size; + unsigned int uncompressed_alloc; + uint8_t *uncompressed_buffer; + unsigned int uncompressed_offset; + + unsigned int mask_size; + uint8_t *mask_buffer; + + unsigned int compressed_size; + void *compressed_buffer; + +#if LIBDEFLATE_SUPPORT + struct libdeflate_decompressor* libdeflate_dec; + struct libdeflate_compressor* libdeflate_enc; +#endif + + TIFFVGetMethod vgetparent; /* super-class method */ + TIFFVSetMethod vsetparent; /* super-class method */ +} LERCState; + +#define LState(tif) ((LERCState*) (tif)->tif_data) +#define DecoderState(tif) LState(tif) +#define EncoderState(tif) LState(tif) + +static int LERCEncode(TIFF* tif, uint8_t* bp, tmsize_t cc, uint16_t s); +static int LERCDecode(TIFF* tif, uint8_t* op, tmsize_t occ, uint16_t s); + +static int +LERCFixupTags(TIFF* tif) +{ + (void) tif; + return 1; +} + +static int +LERCSetupDecode(TIFF* tif) +{ + LERCState* sp = DecoderState(tif); + + assert(sp != NULL); + + /* if we were last encoding, terminate this mode */ + if (sp->state & LSTATE_INIT_ENCODE) { + sp->state = 0; + } + + sp->state |= LSTATE_INIT_DECODE; + return 1; +} + +static int GetLercDataType(TIFF* tif) +{ + TIFFDirectory *td = &tif->tif_dir; + static const char module[] = "GetLercDataType"; + + if( td->td_sampleformat == SAMPLEFORMAT_INT && + td->td_bitspersample == 8 ) + { + return 0; + } + + if( td->td_sampleformat == SAMPLEFORMAT_UINT && + td->td_bitspersample == 8 ) + { + return 1; + } + + if( td->td_sampleformat == SAMPLEFORMAT_INT && + td->td_bitspersample == 16 ) + { + return 2; + } + + if( td->td_sampleformat == SAMPLEFORMAT_UINT && + td->td_bitspersample == 16 ) + { + return 3; + } + + if( td->td_sampleformat == SAMPLEFORMAT_INT && + td->td_bitspersample == 32 ) + { + return 4; + } + + if( td->td_sampleformat == SAMPLEFORMAT_UINT && + td->td_bitspersample == 32 ) + { + return 5; + } + + if( td->td_sampleformat == SAMPLEFORMAT_IEEEFP && + td->td_bitspersample == 32 ) + { + return 6; + } + + if( td->td_sampleformat == SAMPLEFORMAT_IEEEFP && + td->td_bitspersample == 64 ) + { + return 7; + } + + TIFFErrorExt(tif->tif_clientdata, module, + "Unsupported combination of SampleFormat and td_bitspersample"); + return -1; +} + +static int SetupUncompressedBuffer(TIFF* tif, LERCState* sp, + const char* module) +{ + TIFFDirectory *td = &tif->tif_dir; + uint64_t new_size_64; + uint64_t new_alloc_64; + unsigned int new_size; + unsigned int new_alloc; + + sp->uncompressed_offset = 0; + + if (isTiled(tif)) { + sp->segment_width = td->td_tilewidth; + sp->segment_height = td->td_tilelength; + } else { + sp->segment_width = td->td_imagewidth; + sp->segment_height = td->td_imagelength - tif->tif_row; + if (sp->segment_height > td->td_rowsperstrip) + sp->segment_height = td->td_rowsperstrip; + } + + new_size_64 = (uint64_t)sp->segment_width * sp->segment_height * + (td->td_bitspersample / 8); + if( td->td_planarconfig == PLANARCONFIG_CONTIG ) + { + new_size_64 *= td->td_samplesperpixel; + } + + new_size = (unsigned int)new_size_64; + sp->uncompressed_size = new_size; + + /* add some margin as we are going to use it also to store deflate/zstd compressed data */ + new_alloc_64 = 100 + new_size_64 + new_size_64 / 3; +#ifdef ZSTD_SUPPORT + { + size_t zstd_max = ZSTD_compressBound((size_t)new_size_64); + if( new_alloc_64 < zstd_max ) + { + new_alloc_64 = zstd_max; + } + } +#endif + new_alloc = (unsigned int)new_alloc_64; + if( new_alloc != new_alloc_64 ) + { + TIFFErrorExt(tif->tif_clientdata, module, + "Too large uncompressed strip/tile"); + _TIFFfree(sp->uncompressed_buffer); + sp->uncompressed_buffer = 0; + sp->uncompressed_alloc = 0; + return 0; + } + + if( sp->uncompressed_alloc < new_alloc ) + { + _TIFFfree(sp->uncompressed_buffer); + sp->uncompressed_buffer = _TIFFmalloc(new_alloc); + if( !sp->uncompressed_buffer ) + { + TIFFErrorExt(tif->tif_clientdata, module, + "Cannot allocate buffer"); + _TIFFfree(sp->uncompressed_buffer); + sp->uncompressed_buffer = 0; + sp->uncompressed_alloc = 0; + return 0; + } + sp->uncompressed_alloc = new_alloc; + } + + if( (td->td_planarconfig == PLANARCONFIG_CONTIG && + td->td_extrasamples > 0 && + td->td_sampleinfo[td->td_extrasamples-1] == EXTRASAMPLE_UNASSALPHA && + GetLercDataType(tif) == 1 ) || + (td->td_sampleformat == SAMPLEFORMAT_IEEEFP && + (td->td_planarconfig == PLANARCONFIG_SEPARATE || + td->td_samplesperpixel == 1) && + (td->td_bitspersample == 32 || td->td_bitspersample == 64 )) ) + { + unsigned int mask_size = sp->segment_width * sp->segment_height; + if( sp->mask_size < mask_size ) + { + void* mask_buffer = _TIFFrealloc(sp->mask_buffer, mask_size); + if( mask_buffer == NULL ) + { + TIFFErrorExt(tif->tif_clientdata, module, + "Cannot allocate buffer"); + sp->mask_size = 0; + _TIFFfree(sp->uncompressed_buffer); + sp->uncompressed_buffer = 0; + sp->uncompressed_alloc = 0; + return 0; + } + sp->mask_buffer = (uint8_t*)mask_buffer; + sp->mask_size = mask_size; + } + } + + return 1; +} + +/* +* Setup state for decoding a strip. +*/ +static int +LERCPreDecode(TIFF* tif, uint16_t s) +{ + static const char module[] = "LERCPreDecode"; + lerc_status lerc_ret; + TIFFDirectory *td = &tif->tif_dir; + LERCState* sp = DecoderState(tif); + int lerc_data_type; + unsigned int infoArray[8]; + unsigned nomask_bands = td->td_samplesperpixel; + int ndims; + int use_mask = 0; + uint8_t* lerc_data = tif->tif_rawcp; + unsigned int lerc_data_size = (unsigned int)tif->tif_rawcc; + + (void) s; + assert(sp != NULL); + if( sp->state != LSTATE_INIT_DECODE ) + tif->tif_setupdecode(tif); + + lerc_data_type = GetLercDataType(tif); + if( lerc_data_type < 0 ) + return 0; + + if( !SetupUncompressedBuffer(tif, sp, module) ) + return 0; + + if( sp->additional_compression != LERC_ADD_COMPRESSION_NONE ) + { + if( sp->compressed_size < sp->uncompressed_alloc ) + { + _TIFFfree(sp->compressed_buffer); + sp->compressed_buffer = _TIFFmalloc(sp->uncompressed_alloc); + if( !sp->compressed_buffer ) + { + sp->compressed_size = 0; + return 0; + } + sp->compressed_size = sp->uncompressed_alloc; + } + } + + if( sp->additional_compression == LERC_ADD_COMPRESSION_DEFLATE ) + { +#if LIBDEFLATE_SUPPORT + enum libdeflate_result res; + size_t lerc_data_sizet = 0; + if( sp->libdeflate_dec == NULL ) + { + sp->libdeflate_dec = libdeflate_alloc_decompressor(); + if( sp->libdeflate_dec == NULL ) + { + TIFFErrorExt(tif->tif_clientdata, module, + "Cannot allocate decompressor"); + return 0; + } + } + + res = libdeflate_zlib_decompress( + sp->libdeflate_dec, tif->tif_rawcp, (size_t)tif->tif_rawcc, + sp->compressed_buffer, sp->compressed_size, + &lerc_data_sizet); + if( res != LIBDEFLATE_SUCCESS ) + { + TIFFErrorExt(tif->tif_clientdata, module, + "Decoding error at scanline %lu", + (unsigned long) tif->tif_row); + return 0; + } + assert( lerc_data_sizet == (unsigned int)lerc_data_sizet ); + lerc_data = sp->compressed_buffer; + lerc_data_size = (unsigned int)lerc_data_sizet; +#else + z_stream strm; + int zlib_ret; + + memset(&strm, 0, sizeof(strm)); + strm.zalloc = NULL; + strm.zfree = NULL; + strm.opaque = NULL; + zlib_ret = inflateInit(&strm); + if( zlib_ret != Z_OK ) + { + TIFFErrorExt(tif->tif_clientdata, module, + "inflateInit() failed"); + inflateEnd(&strm); + return 0; + } + + strm.avail_in = (uInt)tif->tif_rawcc; + strm.next_in = tif->tif_rawcp; + strm.avail_out = sp->compressed_size; + strm.next_out = sp->compressed_buffer; + zlib_ret = inflate(&strm, Z_FINISH); + if( zlib_ret != Z_STREAM_END && zlib_ret != Z_OK ) + { + TIFFErrorExt(tif->tif_clientdata, module, + "inflate() failed"); + inflateEnd(&strm); + return 0; + } + lerc_data = sp->compressed_buffer; + lerc_data_size = sp->compressed_size - strm.avail_out; + inflateEnd(&strm); +#endif + } + else if( sp->additional_compression == LERC_ADD_COMPRESSION_ZSTD ) + { +#ifdef ZSTD_SUPPORT + size_t zstd_ret; + + zstd_ret = ZSTD_decompress(sp->compressed_buffer, + sp->compressed_size, + tif->tif_rawcp, + tif->tif_rawcc); + if( ZSTD_isError(zstd_ret) ) { + TIFFErrorExt(tif->tif_clientdata, module, + "Error in ZSTD_decompress(): %s", + ZSTD_getErrorName(zstd_ret)); + return 0; + } + + lerc_data = sp->compressed_buffer; + lerc_data_size = (unsigned int)zstd_ret; +#else + TIFFErrorExt(tif->tif_clientdata, module, "ZSTD support missing"); + return 0; +#endif + } + else if( sp->additional_compression != LERC_ADD_COMPRESSION_NONE ) + { + TIFFErrorExt(tif->tif_clientdata, module, + "Unhandled additional compression"); + return 0; + } + + lerc_ret = lerc_getBlobInfo( + lerc_data, + lerc_data_size, + infoArray, + NULL, + 8, + 0); + if( lerc_ret != 0 ) + { + TIFFErrorExt(tif->tif_clientdata, module, + "lerc_getBlobInfo() failed"); + return 0; + } + + /* If the configuration is compatible of a LERC mask, and that the */ + /* LERC info has dim == samplesperpixel - 1, then there is a LERC */ + /* mask. */ + if( td->td_planarconfig == PLANARCONFIG_CONTIG && + td->td_extrasamples > 0 && + td->td_sampleinfo[td->td_extrasamples-1] == EXTRASAMPLE_UNASSALPHA && + GetLercDataType(tif) == 1 && + infoArray[2] == td->td_samplesperpixel - 1U ) + { + use_mask = 1; + nomask_bands --; + } + else if( td->td_sampleformat == SAMPLEFORMAT_IEEEFP && + (td->td_planarconfig == PLANARCONFIG_SEPARATE || + td->td_samplesperpixel == 1) && + (td->td_bitspersample == 32 || td->td_bitspersample == 64) ) + { + use_mask = 1; + } + + ndims = td->td_planarconfig == PLANARCONFIG_CONTIG ? + nomask_bands : 1; + + /* Info returned in infoArray is { version, dataType, nDim, nCols, + nRows, nBands, nValidPixels, blobSize } */ + if( infoArray[0] != (unsigned)sp->lerc_version ) + { + TIFFWarningExt(tif->tif_clientdata, module, + "Unexpected version number: %d. Expected: %d", + infoArray[0], sp->lerc_version); + } + if( infoArray[1] != (unsigned)lerc_data_type ) + { + TIFFErrorExt(tif->tif_clientdata, module, + "Unexpected dataType: %d. Expected: %d", + infoArray[1], lerc_data_type); + return 0; + } + if( infoArray[2] != (unsigned)ndims ) + { + TIFFErrorExt(tif->tif_clientdata, module, + "Unexpected nDim: %d. Expected: %d", + infoArray[2], ndims); + return 0; + } + if( infoArray[3] != sp->segment_width ) + { + TIFFErrorExt(tif->tif_clientdata, module, + "Unexpected nCols: %d. Expected: %du", + infoArray[3], sp->segment_width); + return 0; + } + if( infoArray[4] != sp->segment_height ) + { + TIFFErrorExt(tif->tif_clientdata, module, + "Unexpected nRows: %d. Expected: %u", + infoArray[4], sp->segment_height); + return 0; + } + if( infoArray[5] != 1 ) + { + TIFFErrorExt(tif->tif_clientdata, module, + "Unexpected nBands: %d. Expected: %d", + infoArray[5], 1); + return 0; + } + if( infoArray[7] != lerc_data_size ) + { + TIFFErrorExt(tif->tif_clientdata, module, + "Unexpected blobSize: %d. Expected: %u", + infoArray[7], + lerc_data_size); + return 0; + } + + lerc_ret = lerc_decode( + lerc_data, + lerc_data_size, +#if LERC_AT_LEAST_VERSION(3,0,0) + use_mask ? 1 : 0, +#endif + use_mask ? sp->mask_buffer : NULL, + ndims, + sp->segment_width, + sp->segment_height, + 1, + lerc_data_type, + sp->uncompressed_buffer); + if( lerc_ret != 0 ) + { + TIFFErrorExt(tif->tif_clientdata, module, + "lerc_decode() failed"); + return 0; + } + + /* Interleave alpha mask with other samples. */ + if( use_mask && GetLercDataType(tif) == 1 ) + { + unsigned src_stride = + (td->td_samplesperpixel - 1) * (td->td_bitspersample / 8); + unsigned dst_stride = + td->td_samplesperpixel * (td->td_bitspersample / 8); + unsigned i = sp->segment_width * sp->segment_height; + /* Operate from end to begin to be able to move in place */ + while( i > 0 && i > nomask_bands ) + { + i --; + sp->uncompressed_buffer[ + i * dst_stride + td->td_samplesperpixel - 1] = + 255 * sp->mask_buffer[i]; + memcpy( sp->uncompressed_buffer + i * dst_stride, + sp->uncompressed_buffer + i * src_stride, + src_stride ); + } + /* First pixels must use memmove due to overlapping areas */ + while( i > 0 ) + { + i --; + sp->uncompressed_buffer[ + i * dst_stride + td->td_samplesperpixel - 1] = + 255 * sp->mask_buffer[i]; + memmove( sp->uncompressed_buffer + i * dst_stride, + sp->uncompressed_buffer + i * src_stride, + src_stride ); + } + } + else if( use_mask && td->td_sampleformat == SAMPLEFORMAT_IEEEFP ) + { + const unsigned nb_pixels = sp->segment_width * sp->segment_height; + unsigned i; +#if HOST_BIGENDIAN + const unsigned char nan_bytes[] = { 0x7f, 0xc0, 0, 0 }; +#else + const unsigned char nan_bytes[] = { 0, 0, 0xc0, 0x7f }; +#endif + float nan_float32; + memcpy(&nan_float32, nan_bytes, 4); + + if( td->td_bitspersample == 32 ) + { + for( i = 0; i < nb_pixels; i++ ) + { + if( sp->mask_buffer[i] == 0 ) + ((float*)sp->uncompressed_buffer)[i] = nan_float32; + } + } + else + { + const double nan_float64 = nan_float32; + for( i = 0; i < nb_pixels; i++ ) + { + if( sp->mask_buffer[i] == 0 ) + ((double*)sp->uncompressed_buffer)[i] = nan_float64; + } + } + } + + return 1; +} + +/* +* Decode a strip, tile or scanline. +*/ +static int +LERCDecode(TIFF* tif, uint8_t* op, tmsize_t occ, uint16_t s) +{ + static const char module[] = "LERCDecode"; + LERCState* sp = DecoderState(tif); + + (void) s; + assert(sp != NULL); + assert(sp->state == LSTATE_INIT_DECODE); + + if( sp->uncompressed_buffer == 0 ) + { + TIFFErrorExt(tif->tif_clientdata, module, + "Uncompressed buffer not allocated"); + return 0; + } + + if( (uint64_t)sp->uncompressed_offset + + (uint64_t)occ > sp->uncompressed_size ) + { + TIFFErrorExt(tif->tif_clientdata, module, + "Too many bytes read"); + return 0; + } + + memcpy(op, + sp->uncompressed_buffer + sp->uncompressed_offset, + occ); + sp->uncompressed_offset += (unsigned)occ; + + return 1; +} + +static int +LERCSetupEncode(TIFF* tif) +{ + LERCState* sp = EncoderState(tif); + + assert(sp != NULL); + if (sp->state & LSTATE_INIT_DECODE) { + sp->state = 0; + } + + sp->state |= LSTATE_INIT_ENCODE; + + return 1; +} + +/* +* Reset encoding state at the start of a strip. +*/ +static int +LERCPreEncode(TIFF* tif, uint16_t s) +{ + static const char module[] = "LERCPreEncode"; + LERCState *sp = EncoderState(tif); + int lerc_data_type; + + (void) s; + assert(sp != NULL); + if( sp->state != LSTATE_INIT_ENCODE ) + tif->tif_setupencode(tif); + + lerc_data_type = GetLercDataType(tif); + if( lerc_data_type < 0 ) + return 0; + + if( !SetupUncompressedBuffer(tif, sp, module) ) + return 0; + + return 1; +} + +/* +* Encode a chunk of pixels. +*/ +static int +LERCEncode(TIFF* tif, uint8_t* bp, tmsize_t cc, uint16_t s) +{ + static const char module[] = "LERCEncode"; + LERCState *sp = EncoderState(tif); + + (void)s; + assert(sp != NULL); + assert(sp->state == LSTATE_INIT_ENCODE); + + if( (uint64_t)sp->uncompressed_offset + + (uint64_t)cc > sp->uncompressed_size ) + { + TIFFErrorExt(tif->tif_clientdata, module, + "Too many bytes written"); + return 0; + } + + memcpy(sp->uncompressed_buffer + sp->uncompressed_offset, + bp, cc); + sp->uncompressed_offset += (unsigned)cc; + + return 1; +} + +/* +* Finish off an encoded strip by flushing it. +*/ +static int +LERCPostEncode(TIFF* tif) +{ + lerc_status lerc_ret; + static const char module[] = "LERCPostEncode"; + LERCState *sp = EncoderState(tif); + unsigned int numBytes = 0; + unsigned int numBytesWritten = 0; + TIFFDirectory *td = &tif->tif_dir; + int use_mask = 0; + unsigned dst_nbands = td->td_samplesperpixel; + + if( sp->uncompressed_offset != sp->uncompressed_size ) + { + TIFFErrorExt(tif->tif_clientdata, module, + "Unexpected number of bytes in the buffer"); + return 0; + } + + /* Extract alpha mask (if containing only 0 and 255 values, */ + /* and compact array of regular bands */ + if( td->td_planarconfig == PLANARCONFIG_CONTIG && + td->td_extrasamples > 0 && + td->td_sampleinfo[td->td_extrasamples-1] == EXTRASAMPLE_UNASSALPHA && + GetLercDataType(tif) == 1 ) + { + const unsigned dst_stride = (td->td_samplesperpixel - 1) * + (td->td_bitspersample / 8); + const unsigned src_stride = td->td_samplesperpixel * + (td->td_bitspersample / 8); + unsigned i = 0; + const unsigned nb_pixels = sp->segment_width * sp->segment_height; + + use_mask = 1; + for( i = 0 ; i < nb_pixels; i++) + { + int v = sp->uncompressed_buffer[ + i * src_stride + td->td_samplesperpixel - 1]; + if( v != 0 && v != 255 ) + { + use_mask = 0; + break; + } + } + + if( use_mask ) + { + dst_nbands --; + /* First pixels must use memmove due to overlapping areas */ + for( i = 0 ;i < dst_nbands && i < nb_pixels; i++) + { + memmove( sp->uncompressed_buffer + i * dst_stride, + sp->uncompressed_buffer + i * src_stride, + dst_stride ); + sp->mask_buffer[i] = sp->uncompressed_buffer[ + i * src_stride + td->td_samplesperpixel - 1]; + } + for(; i < nb_pixels; i++) + { + memcpy( sp->uncompressed_buffer + i * dst_stride, + sp->uncompressed_buffer + i * src_stride, + dst_stride ); + sp->mask_buffer[i] = sp->uncompressed_buffer[ + i * src_stride + td->td_samplesperpixel - 1]; + } + } + } + else if( td->td_sampleformat == SAMPLEFORMAT_IEEEFP && + (td->td_planarconfig == PLANARCONFIG_SEPARATE || + dst_nbands == 1) && + (td->td_bitspersample == 32 || td->td_bitspersample == 64 ) ) + { + /* Check for NaN values */ + unsigned i; + const unsigned nb_pixels = sp->segment_width * sp->segment_height; + if( td->td_bitspersample == 32 ) + { + for( i = 0; i < nb_pixels; i++ ) + { + const float val = ((float*)sp->uncompressed_buffer)[i]; + if( val != val ) + { + use_mask = 1; + break; + } + } + } + else + { + for( i = 0; i < nb_pixels; i++ ) + { + const double val = ((double*)sp->uncompressed_buffer)[i]; + if( val != val ) + { + use_mask = 1; + break; + } + } + } + + if( use_mask ) + { + if( td->td_bitspersample == 32 ) + { + for( i = 0; i < nb_pixels; i++ ) + { + const float val = ((float*)sp->uncompressed_buffer)[i]; + sp->mask_buffer[i] = ( val == val ) ? 255 : 0; + } + } + else + { + for( i = 0; i < nb_pixels; i++ ) + { + const double val = ((double*)sp->uncompressed_buffer)[i]; + sp->mask_buffer[i] = ( val == val ) ? 255 : 0; + } + } + } + } + + +#if 0 + lerc_ret = lerc_computeCompressedSize( + sp->uncompressed_buffer, + sp->lerc_version, + GetLercDataType(tif), + td->td_planarconfig == PLANARCONFIG_CONTIG ? + dst_nbands : 1, + sp->segment_width, + sp->segment_height, + 1, + use_mask ? sp->mask_buffer : NULL, + sp->maxzerror, + &numBytes); + if( lerc_ret != 0 ) + { + TIFFErrorExt(tif->tif_clientdata, module, + "lerc_computeCompressedSize() failed"); + return 0; + } +#else + numBytes = sp->uncompressed_alloc; +#endif + + if( sp->compressed_size < numBytes ) + { + _TIFFfree(sp->compressed_buffer); + sp->compressed_buffer = _TIFFmalloc(numBytes); + if( !sp->compressed_buffer ) + { + sp->compressed_size = 0; + return 0; + } + sp->compressed_size = numBytes; + } + + lerc_ret = lerc_encodeForVersion( + sp->uncompressed_buffer, + sp->lerc_version, + GetLercDataType(tif), + td->td_planarconfig == PLANARCONFIG_CONTIG ? + dst_nbands : 1, + sp->segment_width, + sp->segment_height, + 1, +#if LERC_AT_LEAST_VERSION(3,0,0) + use_mask ? 1 : 0, +#endif + use_mask ? sp->mask_buffer : NULL, + sp->maxzerror, + sp->compressed_buffer, + sp->compressed_size, + &numBytesWritten); + if( lerc_ret != 0 ) + { + TIFFErrorExt(tif->tif_clientdata, module, + "lerc_encode() failed"); + return 0; + } + assert( numBytesWritten < numBytes ); + + if( sp->additional_compression == LERC_ADD_COMPRESSION_DEFLATE ) + { +#if LIBDEFLATE_SUPPORT + if( sp->libdeflate_enc == NULL ) + { + /* To get results as good as zlib, we ask for an extra */ + /* level of compression */ + sp->libdeflate_enc = libdeflate_alloc_compressor( + sp->zipquality == Z_DEFAULT_COMPRESSION ? 7 : + sp->zipquality >= 6 && sp->zipquality <= 9 ? sp->zipquality + 1 : + sp->zipquality); + if( sp->libdeflate_enc == NULL ) + { + TIFFErrorExt(tif->tif_clientdata, module, + "Cannot allocate compressor"); + return 0; + } + } + + /* Should not happen normally */ + if( libdeflate_zlib_compress_bound(sp->libdeflate_enc, numBytesWritten) > + sp->uncompressed_alloc ) + { + TIFFErrorExt(tif->tif_clientdata, module, + "Output buffer for libdeflate too small"); + return 0; + } + + tif->tif_rawcc = libdeflate_zlib_compress( + sp->libdeflate_enc, + sp->compressed_buffer, numBytesWritten, + sp->uncompressed_buffer, sp->uncompressed_alloc); + + if( tif->tif_rawcc == 0 ) + { + TIFFErrorExt(tif->tif_clientdata, module, + "Encoder error at scanline %lu", + (unsigned long) tif->tif_row); + return 0; + } +#else + z_stream strm; + int zlib_ret; + int cappedQuality = sp->zipquality; + if( cappedQuality > Z_BEST_COMPRESSION ) + cappedQuality = Z_BEST_COMPRESSION; + + memset(&strm, 0, sizeof(strm)); + strm.zalloc = NULL; + strm.zfree = NULL; + strm.opaque = NULL; + zlib_ret = deflateInit(&strm, cappedQuality); + if( zlib_ret != Z_OK ) + { + TIFFErrorExt(tif->tif_clientdata, module, + "deflateInit() failed"); + return 0; + } + + strm.avail_in = numBytesWritten; + strm.next_in = sp->compressed_buffer; + strm.avail_out = sp->uncompressed_alloc; + strm.next_out = sp->uncompressed_buffer; + zlib_ret = deflate(&strm, Z_FINISH); + if( zlib_ret == Z_STREAM_END ) + { + tif->tif_rawcc = sp->uncompressed_alloc - strm.avail_out; + } + deflateEnd(&strm); + if( zlib_ret != Z_STREAM_END ) + { + TIFFErrorExt(tif->tif_clientdata, module, + "deflate() failed"); + return 0; + } +#endif + { + int ret; + uint8_t* tif_rawdata_backup = tif->tif_rawdata; + tif->tif_rawdata = sp->uncompressed_buffer; + ret = TIFFFlushData1(tif); + tif->tif_rawdata = tif_rawdata_backup; + if( !ret ) + { + return 0; + } + } + } + else if( sp->additional_compression == LERC_ADD_COMPRESSION_ZSTD ) + { +#ifdef ZSTD_SUPPORT + size_t zstd_ret = ZSTD_compress( sp->uncompressed_buffer, + sp->uncompressed_alloc, + sp->compressed_buffer, + numBytesWritten, + sp->zstd_compress_level ); + if( ZSTD_isError(zstd_ret) ) { + TIFFErrorExt(tif->tif_clientdata, module, + "Error in ZSTD_compress(): %s", + ZSTD_getErrorName(zstd_ret)); + return 0; + } + + { + int ret; + uint8_t* tif_rawdata_backup = tif->tif_rawdata; + tif->tif_rawdata = sp->uncompressed_buffer; + tif->tif_rawcc = zstd_ret; + ret = TIFFFlushData1(tif); + tif->tif_rawdata = tif_rawdata_backup; + if( !ret ) + { + return 0; + } + } +#else + TIFFErrorExt(tif->tif_clientdata, module, "ZSTD support missing"); + return 0; +#endif + } + else if( sp->additional_compression != LERC_ADD_COMPRESSION_NONE ) + { + TIFFErrorExt(tif->tif_clientdata, module, + "Unhandled additional compression"); + return 0; + } + else + { + int ret; + uint8_t* tif_rawdata_backup = tif->tif_rawdata; + tif->tif_rawdata = sp->compressed_buffer; + tif->tif_rawcc = numBytesWritten; + ret = TIFFFlushData1(tif); + tif->tif_rawdata = tif_rawdata_backup; + if( !ret ) + return 0; + } + + return 1; +} + +static void +LERCCleanup(TIFF* tif) +{ + LERCState* sp = LState(tif); + + assert(sp != 0); + + tif->tif_tagmethods.vgetfield = sp->vgetparent; + tif->tif_tagmethods.vsetfield = sp->vsetparent; + + _TIFFfree(sp->uncompressed_buffer); + _TIFFfree(sp->compressed_buffer); + _TIFFfree(sp->mask_buffer); + +#if LIBDEFLATE_SUPPORT + if( sp->libdeflate_dec ) + libdeflate_free_decompressor(sp->libdeflate_dec); + if( sp->libdeflate_enc ) + libdeflate_free_compressor(sp->libdeflate_enc); +#endif + + _TIFFfree(sp); + tif->tif_data = NULL; + + _TIFFSetDefaultCompressionState(tif); +} + +static const TIFFField LERCFields[] = { + { TIFFTAG_LERC_PARAMETERS, TIFF_VARIABLE2, TIFF_VARIABLE2, + TIFF_LONG, 0, TIFF_SETGET_C32_UINT32, TIFF_SETGET_UNDEFINED, + FIELD_CUSTOM, FALSE, TRUE, "LercParameters", NULL }, + { TIFFTAG_LERC_MAXZERROR, 0, 0, TIFF_ANY, 0, TIFF_SETGET_DOUBLE, + TIFF_SETGET_UNDEFINED, + FIELD_PSEUDO, TRUE, FALSE, "LercMaximumError", NULL }, + { TIFFTAG_LERC_VERSION, 0, 0, TIFF_ANY, 0, TIFF_SETGET_UINT32, + TIFF_SETGET_UNDEFINED, + FIELD_PSEUDO, FALSE, FALSE, "LercVersion", NULL }, + { TIFFTAG_LERC_ADD_COMPRESSION, 0, 0, TIFF_ANY, 0, TIFF_SETGET_UINT32, + TIFF_SETGET_UNDEFINED, + FIELD_PSEUDO, FALSE, FALSE, "LercAdditionalCompression", NULL }, + { TIFFTAG_ZSTD_LEVEL, 0, 0, TIFF_ANY, 0, TIFF_SETGET_INT, + TIFF_SETGET_UNDEFINED, + FIELD_PSEUDO, TRUE, FALSE, "ZSTD zstd_compress_level", NULL }, + { TIFFTAG_ZIPQUALITY, 0, 0, TIFF_ANY, 0, TIFF_SETGET_INT, + TIFF_SETGET_UNDEFINED, FIELD_PSEUDO, TRUE, FALSE, "", NULL }, +}; + +static int LERCVSetFieldBase(TIFF* tif, uint32_t tag, ...) +{ + LERCState* sp = LState(tif); + int ret; + va_list ap; + va_start(ap, tag); + ret = (*sp->vsetparent)(tif, tag, ap); + va_end(ap); + return ret; +} + +static int +LERCVSetField(TIFF* tif, uint32_t tag, va_list ap) +{ + static const char module[] = "LERCVSetField"; + LERCState* sp = LState(tif); + + switch (tag) { + case TIFFTAG_LERC_PARAMETERS: + { + uint32_t count = va_arg(ap, int); + int* params = va_arg(ap, int*); + if( count < 2 ) + { + TIFFErrorExt(tif->tif_clientdata, module, + "Invalid count for LercParameters: %u", count); + return 0; + } + sp->lerc_version = params[0]; + sp->additional_compression = params[1]; + return LERCVSetFieldBase(tif, TIFFTAG_LERC_PARAMETERS, + count, params); + } + case TIFFTAG_LERC_MAXZERROR: + sp->maxzerror = va_arg(ap, double); + return 1; + case TIFFTAG_LERC_VERSION: + { + int params[2] = {0, 0}; + int version = va_arg(ap, int); + if( version != LERC_VERSION_2_4 ) + { + TIFFErrorExt(tif->tif_clientdata, module, + "Invalid value for LercVersion: %d", version); + return 0; + } + sp->lerc_version = version; + params[0] = sp->lerc_version; + params[1] = sp->additional_compression; + return LERCVSetFieldBase(tif, TIFFTAG_LERC_PARAMETERS, + 2, params); + } + case TIFFTAG_LERC_ADD_COMPRESSION: + { + int params[2] = {0, 0}; + int additional_compression = va_arg(ap, int); +#ifndef ZSTD_SUPPORT + if( additional_compression == LERC_ADD_COMPRESSION_ZSTD ) + { + TIFFErrorExt(tif->tif_clientdata, module, + "LERC_ZSTD requested, but ZSTD not available"); + return 0; + } +#endif + if( additional_compression != LERC_ADD_COMPRESSION_NONE && + additional_compression != LERC_ADD_COMPRESSION_DEFLATE && + additional_compression != LERC_ADD_COMPRESSION_ZSTD ) + { + TIFFErrorExt(tif->tif_clientdata, module, + "Invalid value for LercAdditionalCompression: %d", + additional_compression); + return 0; + } + sp->additional_compression = additional_compression; + params[0] = sp->lerc_version; + params[1] = sp->additional_compression; + return LERCVSetFieldBase(tif, TIFFTAG_LERC_PARAMETERS, + 2, params); + } +#ifdef ZSTD_SUPPORT + case TIFFTAG_ZSTD_LEVEL: + { + sp->zstd_compress_level = (int) va_arg(ap, int); + if( sp->zstd_compress_level <= 0 || + sp->zstd_compress_level > ZSTD_maxCLevel() ) + { + TIFFWarningExt(tif->tif_clientdata, module, + "ZSTD_LEVEL should be between 1 and %d", + ZSTD_maxCLevel()); + } + return 1; + } +#endif + case TIFFTAG_ZIPQUALITY: + { + sp->zipquality = (int) va_arg(ap, int); + if( sp->zipquality < Z_DEFAULT_COMPRESSION || + sp->zipquality > LIBDEFLATE_MAX_COMPRESSION_LEVEL ) { + TIFFErrorExt(tif->tif_clientdata, module, + "Invalid ZipQuality value. Should be in [-1,%d] range", + LIBDEFLATE_MAX_COMPRESSION_LEVEL); + return 0; + } + +#if LIBDEFLATE_SUPPORT + if( sp->libdeflate_enc ) + { + libdeflate_free_compressor(sp->libdeflate_enc); + sp->libdeflate_enc = NULL; + } +#endif + + return (1); + } + default: + return (*sp->vsetparent)(tif, tag, ap); + } + /*NOTREACHED*/ +} + +static int +LERCVGetField(TIFF* tif, uint32_t tag, va_list ap) +{ + LERCState* sp = LState(tif); + + switch (tag) { + case TIFFTAG_LERC_MAXZERROR: + *va_arg(ap, double*) = sp->maxzerror; + break; + case TIFFTAG_LERC_VERSION: + *va_arg(ap, int*) = sp->lerc_version; + break; + case TIFFTAG_LERC_ADD_COMPRESSION: + *va_arg(ap, int*) = sp->additional_compression; + break; + case TIFFTAG_ZSTD_LEVEL: + *va_arg(ap, int*) = sp->zstd_compress_level; + break; + case TIFFTAG_ZIPQUALITY: + *va_arg(ap, int*) = sp->zipquality; + break; + default: + return (*sp->vgetparent)(tif, tag, ap); + } + return 1; +} + +int TIFFInitLERC(TIFF* tif, int scheme) +{ + static const char module[] = "TIFFInitLERC"; + LERCState* sp; + + (void) scheme; + assert( scheme == COMPRESSION_LERC ); + + /* + * Merge codec-specific tag information. + */ + if (!_TIFFMergeFields(tif, LERCFields, TIFFArrayCount(LERCFields))) { + TIFFErrorExt(tif->tif_clientdata, module, + "Merging LERC codec-specific tags failed"); + return 0; + } + + /* + * Allocate state block so tag methods have storage to record values. + */ + tif->tif_data = (uint8_t*) _TIFFcalloc(1, sizeof(LERCState)); + if (tif->tif_data == NULL) + goto bad; + sp = LState(tif); + + /* + * Override parent get/set field methods. + */ + sp->vgetparent = tif->tif_tagmethods.vgetfield; + tif->tif_tagmethods.vgetfield = LERCVGetField; /* hook for codec tags */ + sp->vsetparent = tif->tif_tagmethods.vsetfield; + tif->tif_tagmethods.vsetfield = LERCVSetField; /* hook for codec tags */ + + /* + * Install codec methods. + */ + tif->tif_fixuptags = LERCFixupTags; + tif->tif_setupdecode = LERCSetupDecode; + tif->tif_predecode = LERCPreDecode; + tif->tif_decoderow = LERCDecode; + tif->tif_decodestrip = LERCDecode; + tif->tif_decodetile = LERCDecode; + tif->tif_setupencode = LERCSetupEncode; + tif->tif_preencode = LERCPreEncode; + tif->tif_postencode = LERCPostEncode; + tif->tif_encoderow = LERCEncode; + tif->tif_encodestrip = LERCEncode; + tif->tif_encodetile = LERCEncode; + tif->tif_cleanup = LERCCleanup; + + /* Default values for codec-specific fields */ + TIFFSetField(tif, TIFFTAG_LERC_VERSION, LERC_VERSION_2_4); + TIFFSetField(tif, TIFFTAG_LERC_ADD_COMPRESSION, LERC_ADD_COMPRESSION_NONE); + sp->maxzerror = 0.0; + sp->zstd_compress_level = 9; /* default comp. level */ + sp->zipquality = Z_DEFAULT_COMPRESSION; /* default comp. level */ + sp->state = 0; + + return 1; +bad: + TIFFErrorExt(tif->tif_clientdata, module, + "No space for LERC state block"); + return 0; +} +#endif /* LERC_SUPPORT */ diff --git a/tiff/libtiff/tif_luv.c b/tiff/libtiff/tif_luv.c index 3bd02e88..13765eab 100644 --- a/tiff/libtiff/tif_luv.c +++ b/tiff/libtiff/tif_luv.c @@ -161,9 +161,9 @@ struct logLuvState { int encode_meth; /* encoding method */ int pixel_size; /* bytes per pixel */ - uint8* tbuf; /* translation buffer */ + uint8_t* tbuf; /* translation buffer */ tmsize_t tbuflen; /* buffer length */ - void (*tfunc)(LogLuvState*, uint8*, tmsize_t); + void (*tfunc)(LogLuvState*, uint8_t*, tmsize_t); TIFFVSetMethod vgetparent; /* super-class method */ TIFFVSetMethod vsetparent; /* super-class method */ @@ -180,7 +180,7 @@ struct logLuvState { * Decode a string of 16-bit gray pixels. */ static int -LogL16Decode(TIFF* tif, uint8* op, tmsize_t occ, uint16 s) +LogL16Decode(TIFF* tif, uint8_t* op, tmsize_t occ, uint16_t s) { static const char module[] = "LogL16Decode"; LogLuvState* sp = DecoderState(tif); @@ -188,8 +188,8 @@ LogL16Decode(TIFF* tif, uint8* op, tmsize_t occ, uint16 s) tmsize_t i; tmsize_t npixels; unsigned char* bp; - int16* tp; - int16 b; + int16_t* tp; + int16_t b; tmsize_t cc; int rc; @@ -200,14 +200,14 @@ LogL16Decode(TIFF* tif, uint8* op, tmsize_t occ, uint16 s) npixels = occ / sp->pixel_size; if (sp->user_datafmt == SGILOGDATAFMT_16BIT) - tp = (int16*) op; + tp = (int16_t*) op; else { if(sp->tbuflen < npixels) { TIFFErrorExt(tif->tif_clientdata, module, "Translation buffer too short"); return (0); } - tp = (int16*) sp->tbuf; + tp = (int16_t*) sp->tbuf; } _TIFFmemset((void*) tp, 0, npixels*sizeof (tp[0])); @@ -220,35 +220,28 @@ LogL16Decode(TIFF* tif, uint8* op, tmsize_t occ, uint16 s) if( cc < 2 ) break; rc = *bp++ + (2-128); - b = (int16)(*bp++ << shft); + b = (int16_t)(*bp++ << shft); cc -= 2; while (rc-- && i < npixels) tp[i++] |= b; } else { /* non-run */ rc = *bp++; /* nul is noop */ while (--cc && rc-- && i < npixels) - tp[i++] |= (int16)*bp++ << shft; + tp[i++] |= (int16_t)*bp++ << shft; } } if (i != npixels) { -#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__)) TIFFErrorExt(tif->tif_clientdata, module, - "Not enough data at row %lu (short %I64d pixels)", - (unsigned long) tif->tif_row, - (unsigned __int64) (npixels - i)); -#else - TIFFErrorExt(tif->tif_clientdata, module, - "Not enough data at row %lu (short %llu pixels)", - (unsigned long) tif->tif_row, - (unsigned long long) (npixels - i)); -#endif - tif->tif_rawcp = (uint8*) bp; + "Not enough data at row %"PRIu32" (short %"TIFF_SSIZE_FORMAT" pixels)", + tif->tif_row, + npixels - i); + tif->tif_rawcp = (uint8_t*) bp; tif->tif_rawcc = cc; return (0); } } (*sp->tfunc)(sp, op, npixels); - tif->tif_rawcp = (uint8*) bp; + tif->tif_rawcp = (uint8_t*) bp; tif->tif_rawcc = cc; return (1); } @@ -257,7 +250,7 @@ LogL16Decode(TIFF* tif, uint8* op, tmsize_t occ, uint16 s) * Decode a string of 24-bit pixels. */ static int -LogLuvDecode24(TIFF* tif, uint8* op, tmsize_t occ, uint16 s) +LogLuvDecode24(TIFF* tif, uint8_t* op, tmsize_t occ, uint16_t s) { static const char module[] = "LogLuvDecode24"; LogLuvState* sp = DecoderState(tif); @@ -265,7 +258,7 @@ LogLuvDecode24(TIFF* tif, uint8* op, tmsize_t occ, uint16 s) tmsize_t i; tmsize_t npixels; unsigned char* bp; - uint32* tp; + uint32_t* tp; (void)s; assert(s == 0); @@ -274,16 +267,16 @@ LogLuvDecode24(TIFF* tif, uint8* op, tmsize_t occ, uint16 s) npixels = occ / sp->pixel_size; if (sp->user_datafmt == SGILOGDATAFMT_RAW) - tp = (uint32 *)op; + tp = (uint32_t *)op; else { if(sp->tbuflen < npixels) { TIFFErrorExt(tif->tif_clientdata, module, "Translation buffer too short"); return (0); } - tp = (uint32 *) sp->tbuf; + tp = (uint32_t *) sp->tbuf; } - /* copy to array of uint32 */ + /* copy to array of uint32_t */ bp = (unsigned char*) tif->tif_rawcp; cc = tif->tif_rawcc; for (i = 0; i < npixels && cc >= 3; i++) { @@ -291,20 +284,13 @@ LogLuvDecode24(TIFF* tif, uint8* op, tmsize_t occ, uint16 s) bp += 3; cc -= 3; } - tif->tif_rawcp = (uint8*) bp; + tif->tif_rawcp = (uint8_t*) bp; tif->tif_rawcc = cc; if (i != npixels) { -#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__)) - TIFFErrorExt(tif->tif_clientdata, module, - "Not enough data at row %lu (short %I64d pixels)", - (unsigned long) tif->tif_row, - (unsigned __int64) (npixels - i)); -#else TIFFErrorExt(tif->tif_clientdata, module, - "Not enough data at row %lu (short %llu pixels)", - (unsigned long) tif->tif_row, - (unsigned long long) (npixels - i)); -#endif + "Not enough data at row %"PRIu32" (short %"TIFF_SSIZE_FORMAT" pixels)", + tif->tif_row, + npixels - i); return (0); } (*sp->tfunc)(sp, op, npixels); @@ -315,7 +301,7 @@ LogLuvDecode24(TIFF* tif, uint8* op, tmsize_t occ, uint16 s) * Decode a string of 32-bit pixels. */ static int -LogLuvDecode32(TIFF* tif, uint8* op, tmsize_t occ, uint16 s) +LogLuvDecode32(TIFF* tif, uint8_t* op, tmsize_t occ, uint16_t s) { static const char module[] = "LogLuvDecode32"; LogLuvState* sp; @@ -323,8 +309,8 @@ LogLuvDecode32(TIFF* tif, uint8* op, tmsize_t occ, uint16 s) tmsize_t i; tmsize_t npixels; unsigned char* bp; - uint32* tp; - uint32 b; + uint32_t* tp; + uint32_t b; tmsize_t cc; int rc; @@ -336,14 +322,14 @@ LogLuvDecode32(TIFF* tif, uint8* op, tmsize_t occ, uint16 s) npixels = occ / sp->pixel_size; if (sp->user_datafmt == SGILOGDATAFMT_RAW) - tp = (uint32*) op; + tp = (uint32_t*) op; else { if(sp->tbuflen < npixels) { TIFFErrorExt(tif->tif_clientdata, module, "Translation buffer too short"); return (0); } - tp = (uint32*) sp->tbuf; + tp = (uint32_t*) sp->tbuf; } _TIFFmemset((void*) tp, 0, npixels*sizeof (tp[0])); @@ -356,35 +342,28 @@ LogLuvDecode32(TIFF* tif, uint8* op, tmsize_t occ, uint16 s) if( cc < 2 ) break; rc = *bp++ + (2-128); - b = (uint32)*bp++ << shft; + b = (uint32_t)*bp++ << shft; cc -= 2; while (rc-- && i < npixels) tp[i++] |= b; } else { /* non-run */ rc = *bp++; /* nul is noop */ while (--cc && rc-- && i < npixels) - tp[i++] |= (uint32)*bp++ << shft; + tp[i++] |= (uint32_t)*bp++ << shft; } } if (i != npixels) { -#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__)) - TIFFErrorExt(tif->tif_clientdata, module, - "Not enough data at row %lu (short %I64d pixels)", - (unsigned long) tif->tif_row, - (unsigned __int64) (npixels - i)); -#else TIFFErrorExt(tif->tif_clientdata, module, - "Not enough data at row %lu (short %llu pixels)", - (unsigned long) tif->tif_row, - (unsigned long long) (npixels - i)); -#endif - tif->tif_rawcp = (uint8*) bp; + "Not enough data at row %"PRIu32" (short %"TIFF_SSIZE_FORMAT" pixels)", + tif->tif_row, + npixels - i); + tif->tif_rawcp = (uint8_t*) bp; tif->tif_rawcc = cc; return (0); } } (*sp->tfunc)(sp, op, npixels); - tif->tif_rawcp = (uint8*) bp; + tif->tif_rawcp = (uint8_t*) bp; tif->tif_rawcc = cc; return (1); } @@ -395,7 +374,7 @@ LogLuvDecode32(TIFF* tif, uint8* op, tmsize_t occ, uint16 s) * is row by row. */ static int -LogLuvDecodeStrip(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) +LogLuvDecodeStrip(TIFF* tif, uint8_t* bp, tmsize_t cc, uint16_t s) { tmsize_t rowlen = TIFFScanlineSize(tif); @@ -416,7 +395,7 @@ LogLuvDecodeStrip(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) * is row by row. */ static int -LogLuvDecodeTile(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) +LogLuvDecodeTile(TIFF* tif, uint8_t* bp, tmsize_t cc, uint16_t s) { tmsize_t rowlen = TIFFTileRowSize(tif); @@ -435,7 +414,7 @@ LogLuvDecodeTile(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) * Encode a row of 16-bit pixels. */ static int -LogL16Encode(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) +LogL16Encode(TIFF* tif, uint8_t* bp, tmsize_t cc, uint16_t s) { static const char module[] = "LogL16Encode"; LogLuvState* sp = EncoderState(tif); @@ -443,9 +422,9 @@ LogL16Encode(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) tmsize_t i; tmsize_t j; tmsize_t npixels; - uint8* op; - int16* tp; - int16 b; + uint8_t* op; + int16_t* tp; + int16_t b; tmsize_t occ; int rc=0, mask; tmsize_t beg; @@ -456,9 +435,9 @@ LogL16Encode(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) npixels = cc / sp->pixel_size; if (sp->user_datafmt == SGILOGDATAFMT_16BIT) - tp = (int16*) bp; + tp = (int16_t*) bp; else { - tp = (int16*) sp->tbuf; + tp = (int16_t*) sp->tbuf; if(sp->tbuflen < npixels) { TIFFErrorExt(tif->tif_clientdata, module, "Translation buffer too short"); @@ -481,7 +460,7 @@ LogL16Encode(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) } mask = 0xff << shft; /* find next run */ for (beg = i; beg < npixels; beg += rc) { - b = (int16) (tp[beg] & mask); + b = (int16_t) (tp[beg] & mask); rc = 1; while (rc < 127+2 && beg+rc < npixels && (tp[beg+rc] & mask) == b) @@ -490,12 +469,12 @@ LogL16Encode(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) break; /* long enough */ } if (beg-i > 1 && beg-i < MINRUN) { - b = (int16) (tp[i] & mask);/*check short run */ + b = (int16_t) (tp[i] & mask);/*check short run */ j = i+1; while ((tp[j++] & mask) == b) if (j == beg) { - *op++ = (uint8)(128-2+j-i); - *op++ = (uint8)(b >> shft); + *op++ = (uint8_t)(128 - 2 + j - i); + *op++ = (uint8_t)(b >> shft); occ -= 2; i = beg; break; @@ -511,15 +490,15 @@ LogL16Encode(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) op = tif->tif_rawcp; occ = tif->tif_rawdatasize - tif->tif_rawcc; } - *op++ = (uint8) j; occ--; + *op++ = (uint8_t) j; occ--; while (j--) { - *op++ = (uint8) (tp[i++] >> shft & 0xff); + *op++ = (uint8_t) (tp[i++] >> shft & 0xff); occ--; } } if (rc >= MINRUN) { /* write out run */ - *op++ = (uint8) (128-2+rc); - *op++ = (uint8) (tp[beg] >> shft & 0xff); + *op++ = (uint8_t) (128 - 2 + rc); + *op++ = (uint8_t) (tp[beg] >> shft & 0xff); occ -= 2; } else rc = 0; @@ -535,15 +514,15 @@ LogL16Encode(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) * Encode a row of 24-bit pixels. */ static int -LogLuvEncode24(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) +LogLuvEncode24(TIFF* tif, uint8_t* bp, tmsize_t cc, uint16_t s) { static const char module[] = "LogLuvEncode24"; LogLuvState* sp = EncoderState(tif); tmsize_t i; tmsize_t npixels; tmsize_t occ; - uint8* op; - uint32* tp; + uint8_t* op; + uint32_t* tp; (void)s; assert(s == 0); @@ -551,9 +530,9 @@ LogLuvEncode24(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) npixels = cc / sp->pixel_size; if (sp->user_datafmt == SGILOGDATAFMT_RAW) - tp = (uint32*) bp; + tp = (uint32_t*) bp; else { - tp = (uint32*) sp->tbuf; + tp = (uint32_t*) sp->tbuf; if(sp->tbuflen < npixels) { TIFFErrorExt(tif->tif_clientdata, module, "Translation buffer too short"); @@ -573,9 +552,9 @@ LogLuvEncode24(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) op = tif->tif_rawcp; occ = tif->tif_rawdatasize - tif->tif_rawcc; } - *op++ = (uint8)(*tp >> 16); - *op++ = (uint8)(*tp >> 8 & 0xff); - *op++ = (uint8)(*tp++ & 0xff); + *op++ = (uint8_t)(*tp >> 16); + *op++ = (uint8_t)(*tp >> 8 & 0xff); + *op++ = (uint8_t)(*tp++ & 0xff); occ -= 3; } tif->tif_rawcp = op; @@ -588,7 +567,7 @@ LogLuvEncode24(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) * Encode a row of 32-bit pixels. */ static int -LogLuvEncode32(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) +LogLuvEncode32(TIFF* tif, uint8_t* bp, tmsize_t cc, uint16_t s) { static const char module[] = "LogLuvEncode32"; LogLuvState* sp = EncoderState(tif); @@ -596,9 +575,9 @@ LogLuvEncode32(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) tmsize_t i; tmsize_t j; tmsize_t npixels; - uint8* op; - uint32* tp; - uint32 b; + uint8_t* op; + uint32_t* tp; + uint32_t b; tmsize_t occ; int rc=0, mask; tmsize_t beg; @@ -610,9 +589,9 @@ LogLuvEncode32(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) npixels = cc / sp->pixel_size; if (sp->user_datafmt == SGILOGDATAFMT_RAW) - tp = (uint32*) bp; + tp = (uint32_t*) bp; else { - tp = (uint32*) sp->tbuf; + tp = (uint32_t*) sp->tbuf; if(sp->tbuflen < npixels) { TIFFErrorExt(tif->tif_clientdata, module, "Translation buffer too short"); @@ -648,8 +627,8 @@ LogLuvEncode32(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) j = i+1; while ((tp[j++] & mask) == b) if (j == beg) { - *op++ = (uint8)(128-2+j-i); - *op++ = (uint8)(b >> shft); + *op++ = (uint8_t)(128 - 2 + j - i); + *op++ = (uint8_t)(b >> shft); occ -= 2; i = beg; break; @@ -665,15 +644,15 @@ LogLuvEncode32(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) op = tif->tif_rawcp; occ = tif->tif_rawdatasize - tif->tif_rawcc; } - *op++ = (uint8) j; occ--; + *op++ = (uint8_t) j; occ--; while (j--) { - *op++ = (uint8)(tp[i++] >> shft & 0xff); + *op++ = (uint8_t)(tp[i++] >> shft & 0xff); occ--; } } if (rc >= MINRUN) { /* write out run */ - *op++ = (uint8) (128-2+rc); - *op++ = (uint8)(tp[beg] >> shft & 0xff); + *op++ = (uint8_t) (128 - 2 + rc); + *op++ = (uint8_t)(tp[beg] >> shft & 0xff); occ -= 2; } else rc = 0; @@ -690,7 +669,7 @@ LogLuvEncode32(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) * avoid encoding runs across row boundaries. */ static int -LogLuvEncodeStrip(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) +LogLuvEncodeStrip(TIFF* tif, uint8_t* bp, tmsize_t cc, uint16_t s) { tmsize_t rowlen = TIFFScanlineSize(tif); @@ -710,7 +689,7 @@ LogLuvEncodeStrip(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) * avoid encoding runs across row boundaries. */ static int -LogLuvEncodeTile(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) +LogLuvEncodeTile(TIFF* tif, uint8_t* bp, tmsize_t cc, uint16_t s) { tmsize_t rowlen = TIFFTileRowSize(tif); @@ -790,9 +769,9 @@ LogL16fromY(double Y, int em) /* get 16-bit LogL from Y */ } static void -L16toY(LogLuvState* sp, uint8* op, tmsize_t n) +L16toY(LogLuvState* sp, uint8_t* op, tmsize_t n) { - int16* l16 = (int16*) sp->tbuf; + int16_t* l16 = (int16_t*) sp->tbuf; float* yp = (float*) op; while (n-- > 0) @@ -800,32 +779,32 @@ L16toY(LogLuvState* sp, uint8* op, tmsize_t n) } static void -L16toGry(LogLuvState* sp, uint8* op, tmsize_t n) +L16toGry(LogLuvState* sp, uint8_t* op, tmsize_t n) { - int16* l16 = (int16*) sp->tbuf; - uint8* gp = (uint8*) op; + int16_t* l16 = (int16_t*) sp->tbuf; + uint8_t* gp = (uint8_t*) op; while (n-- > 0) { double Y = LogL16toY(*l16++); - *gp++ = (uint8) ((Y <= 0.) ? 0 : (Y >= 1.) ? 255 : (int)(256.*sqrt(Y))); + *gp++ = (uint8_t) ((Y <= 0.) ? 0 : (Y >= 1.) ? 255 : (int)(256. * sqrt(Y))); } } static void -L16fromY(LogLuvState* sp, uint8* op, tmsize_t n) +L16fromY(LogLuvState* sp, uint8_t* op, tmsize_t n) { - int16* l16 = (int16*) sp->tbuf; + int16_t* l16 = (int16_t*) sp->tbuf; float* yp = (float*) op; while (n-- > 0) - *l16++ = (int16) (LogL16fromY(*yp++, sp->encode_meth)); + *l16++ = (int16_t) (LogL16fromY(*yp++, sp->encode_meth)); } #if !LOGLUV_PUBLIC static #endif void -XYZtoRGB24(float xyz[3], uint8 rgb[3]) +XYZtoRGB24(float xyz[3], uint8_t rgb[3]) { double r, g, b; /* assume CCIR-709 primaries */ @@ -834,9 +813,9 @@ XYZtoRGB24(float xyz[3], uint8 rgb[3]) b = 0.061*xyz[0] + -0.224*xyz[1] + 1.163*xyz[2]; /* assume 2.0 gamma for speed */ /* could use integer sqrt approx., but this is probably faster */ - rgb[0] = (uint8)((r<=0.) ? 0 : (r >= 1.) ? 255 : (int)(256.*sqrt(r))); - rgb[1] = (uint8)((g<=0.) ? 0 : (g >= 1.) ? 255 : (int)(256.*sqrt(g))); - rgb[2] = (uint8)((b<=0.) ? 0 : (b >= 1.) ? 255 : (int)(256.*sqrt(b))); + rgb[0] = (uint8_t)((r <= 0.) ? 0 : (r >= 1.) ? 255 : (int)(256. * sqrt(r))); + rgb[1] = (uint8_t)((g <= 0.) ? 0 : (g >= 1.) ? 255 : (int)(256. * sqrt(g))); + rgb[2] = (uint8_t)((b <= 0.) ? 0 : (b >= 1.) ? 255 : (int)(256. * sqrt(b))); } #if !LOGLUV_PUBLIC @@ -979,7 +958,7 @@ uv_decode(double *up, double *vp, int c) /* decode (u',v') index */ static #endif void -LogLuv24toXYZ(uint32 p, float XYZ[3]) +LogLuv24toXYZ(uint32_t p, float XYZ[3]) { int Ce; double L, u, v, s, x, y; @@ -1006,7 +985,7 @@ LogLuv24toXYZ(uint32 p, float XYZ[3]) #if !LOGLUV_PUBLIC static #endif -uint32 +uint32_t LogLuv24fromXYZ(float XYZ[3], int em) { int Le, Ce; @@ -1030,9 +1009,9 @@ LogLuv24fromXYZ(float XYZ[3], int em) } static void -Luv24toXYZ(LogLuvState* sp, uint8* op, tmsize_t n) +Luv24toXYZ(LogLuvState* sp, uint8_t* op, tmsize_t n) { - uint32* luv = (uint32*) sp->tbuf; + uint32_t* luv = (uint32_t*) sp->tbuf; float* xyz = (float*) op; while (n-- > 0) { @@ -1043,30 +1022,30 @@ Luv24toXYZ(LogLuvState* sp, uint8* op, tmsize_t n) } static void -Luv24toLuv48(LogLuvState* sp, uint8* op, tmsize_t n) +Luv24toLuv48(LogLuvState* sp, uint8_t* op, tmsize_t n) { - uint32* luv = (uint32*) sp->tbuf; - int16* luv3 = (int16*) op; + uint32_t* luv = (uint32_t*) sp->tbuf; + int16_t* luv3 = (int16_t*) op; while (n-- > 0) { double u, v; - *luv3++ = (int16)((*luv >> 12 & 0xffd) + 13314); + *luv3++ = (int16_t)((*luv >> 12 & 0xffd) + 13314); if (uv_decode(&u, &v, *luv&0x3fff) < 0) { u = U_NEU; v = V_NEU; } - *luv3++ = (int16)(u * (1L<<15)); - *luv3++ = (int16)(v * (1L<<15)); + *luv3++ = (int16_t)(u * (1L << 15)); + *luv3++ = (int16_t)(v * (1L << 15)); luv++; } } static void -Luv24toRGB(LogLuvState* sp, uint8* op, tmsize_t n) +Luv24toRGB(LogLuvState* sp, uint8_t* op, tmsize_t n) { - uint32* luv = (uint32*) sp->tbuf; - uint8* rgb = (uint8*) op; + uint32_t* luv = (uint32_t*) sp->tbuf; + uint8_t* rgb = (uint8_t*) op; while (n-- > 0) { float xyz[3]; @@ -1078,9 +1057,9 @@ Luv24toRGB(LogLuvState* sp, uint8* op, tmsize_t n) } static void -Luv24fromXYZ(LogLuvState* sp, uint8* op, tmsize_t n) +Luv24fromXYZ(LogLuvState* sp, uint8_t* op, tmsize_t n) { - uint32* luv = (uint32*) sp->tbuf; + uint32_t* luv = (uint32_t*) sp->tbuf; float* xyz = (float*) op; while (n-- > 0) { @@ -1090,10 +1069,10 @@ Luv24fromXYZ(LogLuvState* sp, uint8* op, tmsize_t n) } static void -Luv24fromLuv48(LogLuvState* sp, uint8* op, tmsize_t n) +Luv24fromLuv48(LogLuvState* sp, uint8_t* op, tmsize_t n) { - uint32* luv = (uint32*) sp->tbuf; - int16* luv3 = (int16*) op; + uint32_t* luv = (uint32_t*) sp->tbuf; + int16_t* luv3 = (int16_t*) op; while (n-- > 0) { int Le, Ce; @@ -1111,7 +1090,7 @@ Luv24fromLuv48(LogLuvState* sp, uint8* op, tmsize_t n) sp->encode_meth); if (Ce < 0) /* never happens */ Ce = uv_encode(U_NEU, V_NEU, SGILOGENCODE_NODITHER); - *luv++ = (uint32)Le << 14 | Ce; + *luv++ = (uint32_t)Le << 14 | Ce; luv3 += 3; } } @@ -1120,7 +1099,7 @@ Luv24fromLuv48(LogLuvState* sp, uint8* op, tmsize_t n) static #endif void -LogLuv32toXYZ(uint32 p, float XYZ[3]) +LogLuv32toXYZ(uint32_t p, float XYZ[3]) { double L, u, v, s, x, y; /* decode luminance */ @@ -1144,7 +1123,7 @@ LogLuv32toXYZ(uint32 p, float XYZ[3]) #if !LOGLUV_PUBLIC static #endif -uint32 +uint32_t LogLuv32fromXYZ(float XYZ[3], int em) { unsigned int Le, ue, ve; @@ -1171,9 +1150,9 @@ LogLuv32fromXYZ(float XYZ[3], int em) } static void -Luv32toXYZ(LogLuvState* sp, uint8* op, tmsize_t n) +Luv32toXYZ(LogLuvState* sp, uint8_t* op, tmsize_t n) { - uint32* luv = (uint32*) sp->tbuf; + uint32_t* luv = (uint32_t*) sp->tbuf; float* xyz = (float*) op; while (n-- > 0) { @@ -1183,28 +1162,28 @@ Luv32toXYZ(LogLuvState* sp, uint8* op, tmsize_t n) } static void -Luv32toLuv48(LogLuvState* sp, uint8* op, tmsize_t n) +Luv32toLuv48(LogLuvState* sp, uint8_t* op, tmsize_t n) { - uint32* luv = (uint32*) sp->tbuf; - int16* luv3 = (int16*) op; + uint32_t* luv = (uint32_t*) sp->tbuf; + int16_t* luv3 = (int16_t*) op; while (n-- > 0) { double u, v; - *luv3++ = (int16)(*luv >> 16); + *luv3++ = (int16_t)(*luv >> 16); u = 1./UVSCALE * ((*luv>>8 & 0xff) + .5); v = 1./UVSCALE * ((*luv & 0xff) + .5); - *luv3++ = (int16)(u * (1L<<15)); - *luv3++ = (int16)(v * (1L<<15)); + *luv3++ = (int16_t)(u * (1L << 15)); + *luv3++ = (int16_t)(v * (1L << 15)); luv++; } } static void -Luv32toRGB(LogLuvState* sp, uint8* op, tmsize_t n) +Luv32toRGB(LogLuvState* sp, uint8_t* op, tmsize_t n) { - uint32* luv = (uint32*) sp->tbuf; - uint8* rgb = (uint8*) op; + uint32_t* luv = (uint32_t*) sp->tbuf; + uint8_t* rgb = (uint8_t*) op; while (n-- > 0) { float xyz[3]; @@ -1216,9 +1195,9 @@ Luv32toRGB(LogLuvState* sp, uint8* op, tmsize_t n) } static void -Luv32fromXYZ(LogLuvState* sp, uint8* op, tmsize_t n) +Luv32fromXYZ(LogLuvState* sp, uint8_t* op, tmsize_t n) { - uint32* luv = (uint32*) sp->tbuf; + uint32_t* luv = (uint32_t*) sp->tbuf; float* xyz = (float*) op; while (n-- > 0) { @@ -1228,30 +1207,30 @@ Luv32fromXYZ(LogLuvState* sp, uint8* op, tmsize_t n) } static void -Luv32fromLuv48(LogLuvState* sp, uint8* op, tmsize_t n) +Luv32fromLuv48(LogLuvState* sp, uint8_t* op, tmsize_t n) { - uint32* luv = (uint32*) sp->tbuf; - int16* luv3 = (int16*) op; + uint32_t* luv = (uint32_t*) sp->tbuf; + int16_t* luv3 = (int16_t*) op; if (sp->encode_meth == SGILOGENCODE_NODITHER) { while (n-- > 0) { - *luv++ = (uint32)luv3[0] << 16 | - (luv3[1]*(uint32)(UVSCALE+.5) >> 7 & 0xff00) | - (luv3[2]*(uint32)(UVSCALE+.5) >> 15 & 0xff); + *luv++ = (uint32_t)luv3[0] << 16 | + (luv3[1]*(uint32_t)(UVSCALE + .5) >> 7 & 0xff00) | + (luv3[2]*(uint32_t)(UVSCALE + .5) >> 15 & 0xff); luv3 += 3; } return; } while (n-- > 0) { - *luv++ = (uint32)luv3[0] << 16 | - (tiff_itrunc(luv3[1]*(UVSCALE/(1<<15)), sp->encode_meth) << 8 & 0xff00) | - (tiff_itrunc(luv3[2]*(UVSCALE/(1<<15)), sp->encode_meth) & 0xff); + *luv++ = (uint32_t)luv3[0] << 16 | + (tiff_itrunc(luv3[1]*(UVSCALE/(1<<15)), sp->encode_meth) << 8 & 0xff00) | + (tiff_itrunc(luv3[2]*(UVSCALE/(1<<15)), sp->encode_meth) & 0xff); luv3 += 3; } } static void -_logLuvNop(LogLuvState* sp, uint8* op, tmsize_t n) +_logLuvNop(LogLuvState* sp, uint8_t* op, tmsize_t n) { (void) sp; (void) op; (void) n; } @@ -1294,7 +1273,7 @@ LogL16InitState(TIFF* tif) if( td->td_samplesperpixel != 1 ) { TIFFErrorExt(tif->tif_clientdata, module, - "Sorry, can not handle LogL image with %s=%d", + "Sorry, can not handle LogL image with %s=%"PRIu16, "Samples/pixel", td->td_samplesperpixel); return 0; } @@ -1307,10 +1286,10 @@ LogL16InitState(TIFF* tif) sp->pixel_size = sizeof (float); break; case SGILOGDATAFMT_16BIT: - sp->pixel_size = sizeof (int16); + sp->pixel_size = sizeof (int16_t); break; case SGILOGDATAFMT_8BIT: - sp->pixel_size = sizeof (uint8); + sp->pixel_size = sizeof (uint8_t); break; default: TIFFErrorExt(tif->tif_clientdata, module, @@ -1323,8 +1302,8 @@ LogL16InitState(TIFF* tif) sp->tbuflen = multiply_ms(td->td_imagewidth, td->td_rowsperstrip); else sp->tbuflen = multiply_ms(td->td_imagewidth, td->td_imagelength); - if (multiply_ms(sp->tbuflen, sizeof (int16)) == 0 || - (sp->tbuf = (uint8*) _TIFFmalloc(sp->tbuflen * sizeof (int16))) == NULL) { + if (multiply_ms(sp->tbuflen, sizeof (int16_t)) == 0 || + (sp->tbuf = (uint8_t*) _TIFFmalloc(sp->tbuflen * sizeof (int16_t))) == NULL) { TIFFErrorExt(tif->tif_clientdata, module, "No space for SGILog translation buffer"); return (0); } @@ -1406,13 +1385,13 @@ LogLuvInitState(TIFF* tif) sp->pixel_size = 3*sizeof (float); break; case SGILOGDATAFMT_16BIT: - sp->pixel_size = 3*sizeof (int16); + sp->pixel_size = 3*sizeof (int16_t); break; case SGILOGDATAFMT_RAW: - sp->pixel_size = sizeof (uint32); + sp->pixel_size = sizeof (uint32_t); break; case SGILOGDATAFMT_8BIT: - sp->pixel_size = 3*sizeof (uint8); + sp->pixel_size = 3*sizeof (uint8_t); break; default: TIFFErrorExt(tif->tif_clientdata, module, @@ -1425,8 +1404,8 @@ LogLuvInitState(TIFF* tif) sp->tbuflen = multiply_ms(td->td_imagewidth, td->td_rowsperstrip); else sp->tbuflen = multiply_ms(td->td_imagewidth, td->td_imagelength); - if (multiply_ms(sp->tbuflen, sizeof (uint32)) == 0 || - (sp->tbuf = (uint8*) _TIFFmalloc(sp->tbuflen * sizeof (uint32))) == NULL) { + if (multiply_ms(sp->tbuflen, sizeof (uint32_t)) == 0 || + (sp->tbuf = (uint8_t*) _TIFFmalloc(sp->tbuflen * sizeof (uint32_t))) == NULL) { TIFFErrorExt(tif->tif_clientdata, module, "No space for SGILog translation buffer"); return (0); } @@ -1495,7 +1474,7 @@ LogLuvSetupDecode(TIFF* tif) return (1); default: TIFFErrorExt(tif->tif_clientdata, module, - "Inappropriate photometric interpretation %d for SGILog compression; %s", + "Inappropriate photometric interpretation %"PRIu16" for SGILog compression; %s", td->td_photometric, "must be either LogLUV or LogL"); break; } @@ -1559,7 +1538,7 @@ LogLuvSetupEncode(TIFF* tif) break; default: TIFFErrorExt(tif->tif_clientdata, module, - "Inappropriate photometric interpretation %d for SGILog compression; %s", + "Inappropriate photometric interpretation %"PRIu16" for SGILog compression; %s", td->td_photometric, "must be either LogLUV or LogL"); return (0); } @@ -1617,7 +1596,7 @@ LogLuvCleanup(TIFF* tif) } static int -LogLuvVSetField(TIFF* tif, uint32 tag, va_list ap) +LogLuvVSetField(TIFF* tif, uint32_t tag, va_list ap) { static const char module[] = "LogLuvVSetField"; LogLuvState* sp = DecoderState(tif); @@ -1680,7 +1659,7 @@ LogLuvVSetField(TIFF* tif, uint32 tag, va_list ap) } static int -LogLuvVGetField(TIFF* tif, uint32 tag, va_list ap) +LogLuvVGetField(TIFF* tif, uint32_t tag, va_list ap) { LogLuvState *sp = (LogLuvState *)tif->tif_data; @@ -1719,7 +1698,7 @@ TIFFInitSGILog(TIFF* tif, int scheme) /* * Allocate state block so tag methods have storage to record values. */ - tif->tif_data = (uint8*) _TIFFmalloc(sizeof (LogLuvState)); + tif->tif_data = (uint8_t*) _TIFFmalloc(sizeof (LogLuvState)); if (tif->tif_data == NULL) goto bad; sp = (LogLuvState*) tif->tif_data; diff --git a/tiff/libtiff/tif_lzma.c b/tiff/libtiff/tif_lzma.c index e150bd63..fc046475 100644 --- a/tiff/libtiff/tif_lzma.c +++ b/tiff/libtiff/tif_lzma.c @@ -61,8 +61,8 @@ typedef struct { #define DecoderState(tif) LState(tif) #define EncoderState(tif) LState(tif) -static int LZMAEncode(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s); -static int LZMADecode(TIFF* tif, uint8* op, tmsize_t occ, uint16 s); +static int LZMAEncode(TIFF* tif, uint8_t* bp, tmsize_t cc, uint16_t s); +static int LZMADecode(TIFF* tif, uint8_t* op, tmsize_t occ, uint16_t s); static const char * LZMAStrerror(lzma_ret ret) @@ -125,7 +125,7 @@ LZMASetupDecode(TIFF* tif) * Setup state for decoding a strip. */ static int -LZMAPreDecode(TIFF* tif, uint16 s) +LZMAPreDecode(TIFF* tif, uint16_t s) { static const char module[] = "LZMAPreDecode"; LZMAState* sp = DecoderState(tif); @@ -160,7 +160,7 @@ LZMAPreDecode(TIFF* tif, uint16 s) } static int -LZMADecode(TIFF* tif, uint8* op, tmsize_t occ, uint16 s) +LZMADecode(TIFF* tif, uint8_t* op, tmsize_t occ, uint16_t s) { static const char module[] = "LZMADecode"; LZMAState* sp = DecoderState(tif); @@ -206,19 +206,19 @@ LZMADecode(TIFF* tif, uint8* op, tmsize_t occ, uint16 s) } if (ret != LZMA_OK) { TIFFErrorExt(tif->tif_clientdata, module, - "Decoding error at scanline %lu, %s", - (unsigned long) tif->tif_row, LZMAStrerror(ret)); + "Decoding error at scanline %"PRIu32", %s", + tif->tif_row, LZMAStrerror(ret)); break; } } while (sp->stream.avail_out > 0); if (sp->stream.avail_out != 0) { TIFFErrorExt(tif->tif_clientdata, module, - "Not enough data at scanline %lu (short %lu bytes)", - (unsigned long) tif->tif_row, (unsigned long) sp->stream.avail_out); + "Not enough data at scanline %"PRIu32" (short %"TIFF_SIZE_FORMAT" bytes)", + tif->tif_row, sp->stream.avail_out); return 0; } - tif->tif_rawcp = (uint8 *)sp->stream.next_in; /* cast away const */ + tif->tif_rawcp = (uint8_t *)sp->stream.next_in; /* cast away const */ tif->tif_rawcc = sp->stream.avail_in; return 1; @@ -243,7 +243,7 @@ LZMASetupEncode(TIFF* tif) * Reset encoding state at the start of a strip. */ static int -LZMAPreEncode(TIFF* tif, uint16 s) +LZMAPreEncode(TIFF* tif, uint16_t s) { static const char module[] = "LZMAPreEncode"; LZMAState *sp = EncoderState(tif); @@ -274,7 +274,7 @@ LZMAPreEncode(TIFF* tif, uint16 s) * Encode a chunk of pixels. */ static int -LZMAEncode(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) +LZMAEncode(TIFF* tif, uint8_t* bp, tmsize_t cc, uint16_t s) { static const char module[] = "LZMAEncode"; LZMAState *sp = EncoderState(tif); @@ -294,8 +294,8 @@ LZMAEncode(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) lzma_ret ret = lzma_code(&sp->stream, LZMA_RUN); if (ret != LZMA_OK) { TIFFErrorExt(tif->tif_clientdata, module, - "Encoding error at scanline %lu, %s", - (unsigned long) tif->tif_row, LZMAStrerror(ret)); + "Encoding error at scanline %"PRIu32", %s", + tif->tif_row, LZMAStrerror(ret)); return 0; } if (sp->stream.avail_out == 0) { @@ -367,7 +367,7 @@ LZMACleanup(TIFF* tif) } static int -LZMAVSetField(TIFF* tif, uint32 tag, va_list ap) +LZMAVSetField(TIFF* tif, uint32_t tag, va_list ap) { static const char module[] = "LZMAVSetField"; LZMAState* sp = LState(tif); @@ -394,7 +394,7 @@ LZMAVSetField(TIFF* tif, uint32 tag, va_list ap) } static int -LZMAVGetField(TIFF* tif, uint32 tag, va_list ap) +LZMAVGetField(TIFF* tif, uint32_t tag, va_list ap) { LZMAState* sp = LState(tif); @@ -435,7 +435,7 @@ TIFFInitLZMA(TIFF* tif, int scheme) /* * Allocate state block so tag methods have storage to record values. */ - tif->tif_data = (uint8*) _TIFFmalloc(sizeof(LZMAState)); + tif->tif_data = (uint8_t*) _TIFFmalloc(sizeof(LZMAState)); if (tif->tif_data == NULL) goto bad; sp = LState(tif); diff --git a/tiff/libtiff/tif_lzw.c b/tiff/libtiff/tif_lzw.c index d92d0fd3..c06aec40 100644 --- a/tiff/libtiff/tif_lzw.c +++ b/tiff/libtiff/tif_lzw.c @@ -107,7 +107,7 @@ typedef struct { /* * Encoding-specific state. */ -typedef uint16 hcode_t; /* codes fit in 16 bits */ +typedef uint16_t hcode_t; /* codes fit in 16 bits */ typedef struct { long hash; hcode_t code; @@ -123,7 +123,7 @@ typedef struct code_ent { unsigned char firstchar; /* first token of string */ } code_t; -typedef int (*decodeFunc)(TIFF*, uint8*, tmsize_t, uint16); +typedef int (*decodeFunc)(TIFF*, uint8_t*, tmsize_t, uint16_t); typedef struct { LZWBaseState base; @@ -132,7 +132,7 @@ typedef struct { long dec_nbitsmask; /* lzw_nbits 1 bits, right adjusted */ long dec_restart; /* restart count */ #ifdef LZW_CHECKEOS - uint64 dec_bitsleft; /* available bits in raw data */ + uint64_t dec_bitsleft; /* available bits in raw data */ tmsize_t old_tif_rawcc; /* value of tif_rawcc at the end of the previous TIFLZWDecode() call */ #endif decodeFunc dec_decode; /* regular or backwards compatible */ @@ -149,7 +149,7 @@ typedef struct { long enc_ratio; /* current compression ratio */ long enc_incount; /* (input) data bytes encoded */ long enc_outcount; /* encoded (output) bytes */ - uint8* enc_rawlimit; /* bound on tif_rawdata buffer */ + uint8_t* enc_rawlimit; /* bound on tif_rawdata buffer */ hash_t* enc_hashtab; /* kept separate for small machines */ } LZWCodecState; @@ -157,9 +157,9 @@ typedef struct { #define DecoderState(tif) ((LZWCodecState*) LZWState(tif)) #define EncoderState(tif) ((LZWCodecState*) LZWState(tif)) -static int LZWDecode(TIFF* tif, uint8* op0, tmsize_t occ0, uint16 s); +static int LZWDecode(TIFF* tif, uint8_t* op0, tmsize_t occ0, uint16_t s); #ifdef LZW_COMPAT -static int LZWDecodeCompat(TIFF* tif, uint8* op0, tmsize_t occ0, uint16 s); +static int LZWDecodeCompat(TIFF* tif, uint8_t* op0, tmsize_t occ0, uint16_t s); #endif static void cl_hash(LZWCodecState*); @@ -173,9 +173,9 @@ static void cl_hash(LZWCodecState*); * strip is suppose to be terminated with CODE_EOI. */ #define NextCode(_tif, _sp, _bp, _code, _get) { \ - if ((_sp)->dec_bitsleft < (uint64)nbits) { \ + if ((_sp)->dec_bitsleft < (uint64_t)nbits) { \ TIFFWarningExt(_tif->tif_clientdata, module, \ - "LZWDecode: Strip %d not terminated with EOI code", \ + "LZWDecode: Strip %"PRIu32" not terminated with EOI code", \ _tif->tif_curstrip); \ _code = CODE_EOI; \ } else { \ @@ -207,7 +207,7 @@ LZWSetupDecode(TIFF* tif) * Allocate state block so tag methods have storage to record * values. */ - tif->tif_data = (uint8*) _TIFFmalloc(sizeof(LZWCodecState)); + tif->tif_data = (uint8_t*) _TIFFmalloc(sizeof(LZWCodecState)); if (tif->tif_data == NULL) { TIFFErrorExt(tif->tif_clientdata, module, "No space for LZW state block"); @@ -256,7 +256,7 @@ LZWSetupDecode(TIFF* tif) * Setup state for decoding a strip. */ static int -LZWPreDecode(TIFF* tif, uint16 s) +LZWPreDecode(TIFF* tif, uint16_t s) { static const char module[] = "LZWPreDecode"; LZWCodecState *sp = DecoderState(tif); @@ -352,12 +352,12 @@ static void codeLoop(TIFF* tif, const char* module) { TIFFErrorExt(tif->tif_clientdata, module, - "Bogus encoding, loop in the code table; scanline %d", + "Bogus encoding, loop in the code table; scanline %"PRIu32, tif->tif_row); } static int -LZWDecode(TIFF* tif, uint8* op0, tmsize_t occ0, uint16 s) +LZWDecode(TIFF* tif, uint8_t* op0, tmsize_t occ0, uint16_t s) { static const char module[] = "LZWDecode"; LZWCodecState *sp = DecoderState(tif); @@ -426,7 +426,7 @@ LZWDecode(TIFF* tif, uint8* op0, tmsize_t occ0, uint16 s) bp = (unsigned char *)tif->tif_rawcp; #ifdef LZW_CHECKEOS - sp->dec_bitsleft += (((uint64)tif->tif_rawcc - sp->old_tif_rawcc) << 3); + sp->dec_bitsleft += (((uint64_t)tif->tif_rawcc - sp->old_tif_rawcc) << 3); #endif nbits = sp->lzw_nbits; nextdata = sp->lzw_nextdata; @@ -454,7 +454,7 @@ LZWDecode(TIFF* tif, uint8* op0, tmsize_t occ0, uint16 s) break; if (code > CODE_CLEAR) { TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "LZWDecode: Corrupted LZW table at scanline %d", + "LZWDecode: Corrupted LZW table at scanline %"PRIu32, tif->tif_row); return (0); } @@ -471,7 +471,7 @@ LZWDecode(TIFF* tif, uint8* op0, tmsize_t occ0, uint16 s) if (free_entp < &sp->dec_codetab[0] || free_entp >= &sp->dec_codetab[CSIZE]) { TIFFErrorExt(tif->tif_clientdata, module, - "Corrupted LZW table at scanline %d", + "Corrupted LZW table at scanline %"PRIu32, tif->tif_row); return (0); } @@ -480,7 +480,7 @@ LZWDecode(TIFF* tif, uint8* op0, tmsize_t occ0, uint16 s) if (free_entp->next < &sp->dec_codetab[0] || free_entp->next >= &sp->dec_codetab[CSIZE]) { TIFFErrorExt(tif->tif_clientdata, module, - "Corrupted LZW table at scanline %d", + "Corrupted LZW table at scanline %"PRIu32, tif->tif_row); return (0); } @@ -503,7 +503,7 @@ LZWDecode(TIFF* tif, uint8* op0, tmsize_t occ0, uint16 s) if(codep->length == 0) { TIFFErrorExt(tif->tif_clientdata, module, "Wrong length of decoded string: " - "data probably corrupted at scanline %d", + "data probably corrupted at scanline %"PRIu32, tif->tif_row); return (0); } @@ -552,8 +552,8 @@ LZWDecode(TIFF* tif, uint8* op0, tmsize_t occ0, uint16 s) } } - tif->tif_rawcc -= (tmsize_t)( (uint8*) bp - tif->tif_rawcp ); - tif->tif_rawcp = (uint8*) bp; + tif->tif_rawcc -= (tmsize_t)((uint8_t*) bp - tif->tif_rawcp ); + tif->tif_rawcp = (uint8_t*) bp; #ifdef LZW_CHECKEOS sp->old_tif_rawcc = tif->tif_rawcc; #endif @@ -566,15 +566,9 @@ LZWDecode(TIFF* tif, uint8* op0, tmsize_t occ0, uint16 s) sp->dec_maxcodep = maxcodep; if (occ > 0) { -#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__)) TIFFErrorExt(tif->tif_clientdata, module, - "Not enough data at scanline %d (short %I64d bytes)", - tif->tif_row, (unsigned __int64) occ); -#else - TIFFErrorExt(tif->tif_clientdata, module, - "Not enough data at scanline %d (short %llu bytes)", - tif->tif_row, (unsigned long long) occ); -#endif + "Not enough data at scanline %"PRIu32" (short %ld bytes)", + tif->tif_row, occ); return (0); } return (1); @@ -597,7 +591,7 @@ LZWDecode(TIFF* tif, uint8* op0, tmsize_t occ0, uint16 s) } static int -LZWDecodeCompat(TIFF* tif, uint8* op0, tmsize_t occ0, uint16 s) +LZWDecodeCompat(TIFF* tif, uint8_t* op0, tmsize_t occ0, uint16_t s) { static const char module[] = "LZWDecodeCompat"; LZWCodecState *sp = DecoderState(tif); @@ -660,7 +654,7 @@ LZWDecodeCompat(TIFF* tif, uint8* op0, tmsize_t occ0, uint16 s) bp = (unsigned char *)tif->tif_rawcp; #ifdef LZW_CHECKEOS - sp->dec_bitsleft += (((uint64)tif->tif_rawcc - sp->old_tif_rawcc) << 3); + sp->dec_bitsleft += (((uint64_t)tif->tif_rawcc - sp->old_tif_rawcc) << 3); #endif nbits = sp->lzw_nbits; nextdata = sp->lzw_nextdata; @@ -688,7 +682,7 @@ LZWDecodeCompat(TIFF* tif, uint8* op0, tmsize_t occ0, uint16 s) break; if (code > CODE_CLEAR) { TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "LZWDecode: Corrupted LZW table at scanline %d", + "LZWDecode: Corrupted LZW table at scanline %"PRIu32, tif->tif_row); return (0); } @@ -705,7 +699,7 @@ LZWDecodeCompat(TIFF* tif, uint8* op0, tmsize_t occ0, uint16 s) if (free_entp < &sp->dec_codetab[0] || free_entp >= &sp->dec_codetab[CSIZE]) { TIFFErrorExt(tif->tif_clientdata, module, - "Corrupted LZW table at scanline %d", tif->tif_row); + "Corrupted LZW table at scanline %"PRIu32, tif->tif_row); return (0); } @@ -713,7 +707,7 @@ LZWDecodeCompat(TIFF* tif, uint8* op0, tmsize_t occ0, uint16 s) if (free_entp->next < &sp->dec_codetab[0] || free_entp->next >= &sp->dec_codetab[CSIZE]) { TIFFErrorExt(tif->tif_clientdata, module, - "Corrupted LZW table at scanline %d", tif->tif_row); + "Corrupted LZW table at scanline %"PRIu32, tif->tif_row); return (0); } free_entp->firstchar = free_entp->next->firstchar; @@ -735,7 +729,7 @@ LZWDecodeCompat(TIFF* tif, uint8* op0, tmsize_t occ0, uint16 s) if(codep->length == 0) { TIFFErrorExt(tif->tif_clientdata, module, "Wrong length of decoded " - "string: data probably corrupted at scanline %d", + "string: data probably corrupted at scanline %"PRIu32, tif->tif_row); return (0); } @@ -776,8 +770,8 @@ LZWDecodeCompat(TIFF* tif, uint8* op0, tmsize_t occ0, uint16 s) } } - tif->tif_rawcc -= (tmsize_t)( (uint8*) bp - tif->tif_rawcp ); - tif->tif_rawcp = (uint8*) bp; + tif->tif_rawcc -= (tmsize_t)((uint8_t*) bp - tif->tif_rawcp ); + tif->tif_rawcp = (uint8_t*) bp; #ifdef LZW_CHECKEOS sp->old_tif_rawcc = tif->tif_rawcc; #endif @@ -790,15 +784,9 @@ LZWDecodeCompat(TIFF* tif, uint8* op0, tmsize_t occ0, uint16 s) sp->dec_maxcodep = maxcodep; if (occ > 0) { -#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__)) TIFFErrorExt(tif->tif_clientdata, module, - "Not enough data at scanline %d (short %I64d bytes)", - tif->tif_row, (unsigned __int64) occ); -#else - TIFFErrorExt(tif->tif_clientdata, module, - "Not enough data at scanline %d (short %llu bytes)", - tif->tif_row, (unsigned long long) occ); -#endif + "Not enough data at scanline %"PRIu32" (short %ld bytes)", + tif->tif_row, occ); return (0); } return (1); @@ -829,7 +817,7 @@ LZWSetupEncode(TIFF* tif) * Reset encoding state at the start of a strip. */ static int -LZWPreEncode(TIFF* tif, uint16 s) +LZWPreEncode(TIFF* tif, uint16_t s) { LZWCodecState *sp = EncoderState(tif); @@ -896,7 +884,7 @@ LZWPreEncode(TIFF* tif, uint16 s) * for the decoder. */ static int -LZWEncode(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) +LZWEncode(TIFF* tif, uint8_t* bp, tmsize_t cc, uint16_t s) { register LZWCodecState *sp = EncoderState(tif); register long fcode; @@ -908,8 +896,8 @@ LZWEncode(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) unsigned long nextdata; long nextbits; int free_ent, maxcode, nbits; - uint8* op; - uint8* limit; + uint8_t* op; + uint8_t* limit; (void) s; if (sp == NULL) @@ -1067,7 +1055,7 @@ static int LZWPostEncode(TIFF* tif) { register LZWCodecState *sp = EncoderState(tif); - uint8* op = tif->tif_rawcp; + uint8_t* op = tif->tif_rawcp; long nextbits = sp->lzw_nextbits; unsigned long nextdata = sp->lzw_nextdata; long outcount = sp->enc_outcount; @@ -1163,7 +1151,7 @@ TIFFInitLZW(TIFF* tif, int scheme) /* * Allocate state block so tag methods have storage to record values. */ - tif->tif_data = (uint8*) _TIFFmalloc(sizeof (LZWCodecState)); + tif->tif_data = (uint8_t*) _TIFFmalloc(sizeof (LZWCodecState)); if (tif->tif_data == NULL) goto bad; DecoderState(tif)->dec_codetab = NULL; diff --git a/tiff/libtiff/tif_next.c b/tiff/libtiff/tif_next.c index 0ba61aed..695fc5d4 100644 --- a/tiff/libtiff/tif_next.c +++ b/tiff/libtiff/tif_next.c @@ -44,12 +44,12 @@ #define WHITE ((1<<2)-1) static int -NeXTDecode(TIFF* tif, uint8* buf, tmsize_t occ, uint16 s) +NeXTDecode(TIFF* tif, uint8_t* buf, tmsize_t occ, uint16_t s) { static const char module[] = "NeXTDecode"; unsigned char *bp, *op; tmsize_t cc; - uint8* row; + uint8_t* row; tmsize_t scanline, n; (void) s; @@ -101,9 +101,9 @@ NeXTDecode(TIFF* tif, uint8* buf, tmsize_t occ, uint16 s) break; } default: { - uint32 npixels = 0, grey; + uint32_t npixels = 0, grey; tmsize_t op_offset = 0; - uint32 imagewidth = tif->tif_dir.td_imagewidth; + uint32_t imagewidth = tif->tif_dir.td_imagewidth; if( isTiled(tif) ) imagewidth = tif->tif_dir.td_tilewidth; @@ -115,7 +115,7 @@ NeXTDecode(TIFF* tif, uint8* buf, tmsize_t occ, uint16 s) */ op = row; for (;;) { - grey = (uint32)((n>>6) & 0x3); + grey = (uint32_t)((n >> 6) & 0x3); n &= 0x3f; /* * Ensure the run does not exceed the scanline @@ -127,8 +127,8 @@ NeXTDecode(TIFF* tif, uint8* buf, tmsize_t occ, uint16 s) if (npixels >= imagewidth) break; if (op_offset >= scanline ) { - TIFFErrorExt(tif->tif_clientdata, module, "Invalid data for scanline %ld", - (long) tif->tif_row); + TIFFErrorExt(tif->tif_clientdata, module, "Invalid data for scanline %"PRIu32, + tif->tif_row); return (0); } if (cc == 0) @@ -140,17 +140,17 @@ NeXTDecode(TIFF* tif, uint8* buf, tmsize_t occ, uint16 s) } } } - tif->tif_rawcp = (uint8*) bp; + tif->tif_rawcp = (uint8_t*) bp; tif->tif_rawcc = cc; return (1); bad: - TIFFErrorExt(tif->tif_clientdata, module, "Not enough data for scanline %ld", - (long) tif->tif_row); + TIFFErrorExt(tif->tif_clientdata, module, "Not enough data for scanline %"PRIu32, + tif->tif_row); return (0); } static int -NeXTPreDecode(TIFF* tif, uint16 s) +NeXTPreDecode(TIFF* tif, uint16_t s) { static const char module[] = "NeXTPreDecode"; TIFFDirectory *td = &tif->tif_dir; @@ -158,7 +158,7 @@ NeXTPreDecode(TIFF* tif, uint16 s) if( td->td_bitspersample != 2 ) { - TIFFErrorExt(tif->tif_clientdata, module, "Unsupported BitsPerSample = %d", + TIFFErrorExt(tif->tif_clientdata, module, "Unsupported BitsPerSample = %"PRIu16, td->td_bitspersample); return (0); } diff --git a/tiff/libtiff/tif_ojpeg.c b/tiff/libtiff/tif_ojpeg.c index d9000764..102f9940 100644 --- a/tiff/libtiff/tif_ojpeg.c +++ b/tiff/libtiff/tif_ojpeg.c @@ -141,7 +141,7 @@ * enough so as to not result in significant call overhead. It should be at least a few * bytes to accommodate some structures (this is verified in asserts), but it would not be * sensible to make it this small anyway, and it should be at most 64K since it is indexed - * with uint16. We recommend 2K. + * with uint16_t. We recommend 2K. * EGYPTIANWALK: You could also define EGYPTIANWALK here, but it is not used anywhere and has * absolutely no effect. That is why most people insist the EGYPTIANWALK is a bit silly. */ @@ -258,118 +258,118 @@ typedef struct { TIFFVGetMethod vgetparent; TIFFVSetMethod vsetparent; TIFFPrintMethod printdir; - uint64 file_size; - uint32 image_width; - uint32 image_length; - uint32 strile_width; - uint32 strile_length; - uint32 strile_length_total; - uint8 samples_per_pixel; - uint8 plane_sample_offset; - uint8 samples_per_pixel_per_plane; - uint64 jpeg_interchange_format; - uint64 jpeg_interchange_format_length; - uint8 jpeg_proc; - uint8 subsamplingcorrect; - uint8 subsamplingcorrect_done; - uint8 subsampling_tag; - uint8 subsampling_hor; - uint8 subsampling_ver; - uint8 subsampling_force_desubsampling_inside_decompression; - uint8 qtable_offset_count; - uint8 dctable_offset_count; - uint8 actable_offset_count; - uint64 qtable_offset[3]; - uint64 dctable_offset[3]; - uint64 actable_offset[3]; - uint8* qtable[4]; - uint8* dctable[4]; - uint8* actable[4]; - uint16 restart_interval; - uint8 restart_index; - uint8 sof_log; - uint8 sof_marker_id; - uint32 sof_x; - uint32 sof_y; - uint8 sof_c[3]; - uint8 sof_hv[3]; - uint8 sof_tq[3]; - uint8 sos_cs[3]; - uint8 sos_tda[3]; + uint64_t file_size; + uint32_t image_width; + uint32_t image_length; + uint32_t strile_width; + uint32_t strile_length; + uint32_t strile_length_total; + uint8_t samples_per_pixel; + uint8_t plane_sample_offset; + uint8_t samples_per_pixel_per_plane; + uint64_t jpeg_interchange_format; + uint64_t jpeg_interchange_format_length; + uint8_t jpeg_proc; + uint8_t subsamplingcorrect; + uint8_t subsamplingcorrect_done; + uint8_t subsampling_tag; + uint8_t subsampling_hor; + uint8_t subsampling_ver; + uint8_t subsampling_force_desubsampling_inside_decompression; + uint8_t qtable_offset_count; + uint8_t dctable_offset_count; + uint8_t actable_offset_count; + uint64_t qtable_offset[3]; + uint64_t dctable_offset[3]; + uint64_t actable_offset[3]; + uint8_t* qtable[4]; + uint8_t* dctable[4]; + uint8_t* actable[4]; + uint16_t restart_interval; + uint8_t restart_index; + uint8_t sof_log; + uint8_t sof_marker_id; + uint32_t sof_x; + uint32_t sof_y; + uint8_t sof_c[3]; + uint8_t sof_hv[3]; + uint8_t sof_tq[3]; + uint8_t sos_cs[3]; + uint8_t sos_tda[3]; struct { - uint8 log; + uint8_t log; OJPEGStateInBufferSource in_buffer_source; - uint32 in_buffer_next_strile; - uint64 in_buffer_file_pos; - uint64 in_buffer_file_togo; + uint32_t in_buffer_next_strile; + uint64_t in_buffer_file_pos; + uint64_t in_buffer_file_togo; } sos_end[3]; - uint8 readheader_done; - uint8 writeheader_done; - uint16 write_cursample; - uint32 write_curstrile; - uint8 libjpeg_session_active; - uint8 libjpeg_jpeg_query_style; + uint8_t readheader_done; + uint8_t writeheader_done; + uint16_t write_cursample; + uint32_t write_curstrile; + uint8_t libjpeg_session_active; + uint8_t libjpeg_jpeg_query_style; jpeg_error_mgr libjpeg_jpeg_error_mgr; jpeg_decompress_struct libjpeg_jpeg_decompress_struct; jpeg_source_mgr libjpeg_jpeg_source_mgr; - uint8 subsampling_convert_log; - uint32 subsampling_convert_ylinelen; - uint32 subsampling_convert_ylines; - uint32 subsampling_convert_clinelen; - uint32 subsampling_convert_clines; - uint32 subsampling_convert_ybuflen; - uint32 subsampling_convert_cbuflen; - uint32 subsampling_convert_ycbcrbuflen; - uint8* subsampling_convert_ycbcrbuf; - uint8* subsampling_convert_ybuf; - uint8* subsampling_convert_cbbuf; - uint8* subsampling_convert_crbuf; - uint32 subsampling_convert_ycbcrimagelen; - uint8** subsampling_convert_ycbcrimage; - uint32 subsampling_convert_clinelenout; - uint32 subsampling_convert_state; - uint32 bytes_per_line; /* if the codec outputs subsampled data, a 'line' in bytes_per_line */ - uint32 lines_per_strile; /* and lines_per_strile means subsampling_ver desubsampled rows */ + uint8_t subsampling_convert_log; + uint32_t subsampling_convert_ylinelen; + uint32_t subsampling_convert_ylines; + uint32_t subsampling_convert_clinelen; + uint32_t subsampling_convert_clines; + uint32_t subsampling_convert_ybuflen; + uint32_t subsampling_convert_cbuflen; + uint32_t subsampling_convert_ycbcrbuflen; + uint8_t* subsampling_convert_ycbcrbuf; + uint8_t* subsampling_convert_ybuf; + uint8_t* subsampling_convert_cbbuf; + uint8_t* subsampling_convert_crbuf; + uint32_t subsampling_convert_ycbcrimagelen; + uint8_t** subsampling_convert_ycbcrimage; + uint32_t subsampling_convert_clinelenout; + uint32_t subsampling_convert_state; + uint32_t bytes_per_line; /* if the codec outputs subsampled data, a 'line' in bytes_per_line */ + uint32_t lines_per_strile; /* and lines_per_strile means subsampling_ver desubsampled rows */ OJPEGStateInBufferSource in_buffer_source; - uint32 in_buffer_next_strile; - uint32 in_buffer_strile_count; - uint64 in_buffer_file_pos; - uint8 in_buffer_file_pos_log; - uint64 in_buffer_file_togo; - uint16 in_buffer_togo; - uint8* in_buffer_cur; - uint8 in_buffer[OJPEG_BUFFER]; + uint32_t in_buffer_next_strile; + uint32_t in_buffer_strile_count; + uint64_t in_buffer_file_pos; + uint8_t in_buffer_file_pos_log; + uint64_t in_buffer_file_togo; + uint16_t in_buffer_togo; + uint8_t* in_buffer_cur; + uint8_t in_buffer[OJPEG_BUFFER]; OJPEGStateOutState out_state; - uint8 out_buffer[OJPEG_BUFFER]; - uint8* skip_buffer; + uint8_t out_buffer[OJPEG_BUFFER]; + uint8_t* skip_buffer; #ifdef GS_TIFF_BUILD jpeg_cust_mem_data jmem; jpeg_cust_mem_data *jmem_parent; #endif } OJPEGState; -static int OJPEGVGetField(TIFF* tif, uint32 tag, va_list ap); -static int OJPEGVSetField(TIFF* tif, uint32 tag, va_list ap); +static int OJPEGVGetField(TIFF* tif, uint32_t tag, va_list ap); +static int OJPEGVSetField(TIFF* tif, uint32_t tag, va_list ap); static void OJPEGPrintDir(TIFF* tif, FILE* fd, long flags); static int OJPEGFixupTags(TIFF* tif); static int OJPEGSetupDecode(TIFF* tif); -static int OJPEGPreDecode(TIFF* tif, uint16 s); +static int OJPEGPreDecode(TIFF* tif, uint16_t s); static int OJPEGPreDecodeSkipRaw(TIFF* tif); static int OJPEGPreDecodeSkipScanlines(TIFF* tif); -static int OJPEGDecode(TIFF* tif, uint8* buf, tmsize_t cc, uint16 s); -static int OJPEGDecodeRaw(TIFF* tif, uint8* buf, tmsize_t cc); -static int OJPEGDecodeScanlines(TIFF* tif, uint8* buf, tmsize_t cc); -static void OJPEGPostDecode(TIFF* tif, uint8* buf, tmsize_t cc); +static int OJPEGDecode(TIFF* tif, uint8_t* buf, tmsize_t cc, uint16_t s); +static int OJPEGDecodeRaw(TIFF* tif, uint8_t* buf, tmsize_t cc); +static int OJPEGDecodeScanlines(TIFF* tif, uint8_t* buf, tmsize_t cc); +static void OJPEGPostDecode(TIFF* tif, uint8_t* buf, tmsize_t cc); static int OJPEGSetupEncode(TIFF* tif); -static int OJPEGPreEncode(TIFF* tif, uint16 s); -static int OJPEGEncode(TIFF* tif, uint8* buf, tmsize_t cc, uint16 s); +static int OJPEGPreEncode(TIFF* tif, uint16_t s); +static int OJPEGEncode(TIFF* tif, uint8_t* buf, tmsize_t cc, uint16_t s); static int OJPEGPostEncode(TIFF* tif); static void OJPEGCleanup(TIFF* tif); static void OJPEGSubsamplingCorrect(TIFF* tif); static int OJPEGReadHeaderInfo(TIFF* tif); -static int OJPEGReadSecondarySos(TIFF* tif, uint16 s); +static int OJPEGReadSecondarySos(TIFF* tif, uint16_t s); static int OJPEGWriteHeaderInfo(TIFF* tif); static void OJPEGLibjpegSessionAbort(TIFF* tif); @@ -377,45 +377,45 @@ static int OJPEGReadHeaderInfoSec(TIFF* tif); static int OJPEGReadHeaderInfoSecStreamDri(TIFF* tif); static int OJPEGReadHeaderInfoSecStreamDqt(TIFF* tif); static int OJPEGReadHeaderInfoSecStreamDht(TIFF* tif); -static int OJPEGReadHeaderInfoSecStreamSof(TIFF* tif, uint8 marker_id); +static int OJPEGReadHeaderInfoSecStreamSof(TIFF* tif, uint8_t marker_id); static int OJPEGReadHeaderInfoSecStreamSos(TIFF* tif); static int OJPEGReadHeaderInfoSecTablesQTable(TIFF* tif); static int OJPEGReadHeaderInfoSecTablesDcTable(TIFF* tif); static int OJPEGReadHeaderInfoSecTablesAcTable(TIFF* tif); static int OJPEGReadBufferFill(OJPEGState* sp); -static int OJPEGReadByte(OJPEGState* sp, uint8* byte); -static int OJPEGReadBytePeek(OJPEGState* sp, uint8* byte); +static int OJPEGReadByte(OJPEGState* sp, uint8_t* byte); +static int OJPEGReadBytePeek(OJPEGState* sp, uint8_t* byte); static void OJPEGReadByteAdvance(OJPEGState* sp); -static int OJPEGReadWord(OJPEGState* sp, uint16* word); -static int OJPEGReadBlock(OJPEGState* sp, uint16 len, void* mem); -static void OJPEGReadSkip(OJPEGState* sp, uint16 len); - -static int OJPEGWriteStream(TIFF* tif, void** mem, uint32* len); -static void OJPEGWriteStreamSoi(TIFF* tif, void** mem, uint32* len); -static void OJPEGWriteStreamQTable(TIFF* tif, uint8 table_index, void** mem, uint32* len); -static void OJPEGWriteStreamDcTable(TIFF* tif, uint8 table_index, void** mem, uint32* len); -static void OJPEGWriteStreamAcTable(TIFF* tif, uint8 table_index, void** mem, uint32* len); -static void OJPEGWriteStreamDri(TIFF* tif, void** mem, uint32* len); -static void OJPEGWriteStreamSof(TIFF* tif, void** mem, uint32* len); -static void OJPEGWriteStreamSos(TIFF* tif, void** mem, uint32* len); -static int OJPEGWriteStreamCompressed(TIFF* tif, void** mem, uint32* len); -static void OJPEGWriteStreamRst(TIFF* tif, void** mem, uint32* len); -static void OJPEGWriteStreamEoi(TIFF* tif, void** mem, uint32* len); +static int OJPEGReadWord(OJPEGState* sp, uint16_t* word); +static int OJPEGReadBlock(OJPEGState* sp, uint16_t len, void* mem); +static void OJPEGReadSkip(OJPEGState* sp, uint16_t len); + +static int OJPEGWriteStream(TIFF* tif, void** mem, uint32_t* len); +static void OJPEGWriteStreamSoi(TIFF* tif, void** mem, uint32_t* len); +static void OJPEGWriteStreamQTable(TIFF* tif, uint8_t table_index, void** mem, uint32_t* len); +static void OJPEGWriteStreamDcTable(TIFF* tif, uint8_t table_index, void** mem, uint32_t* len); +static void OJPEGWriteStreamAcTable(TIFF* tif, uint8_t table_index, void** mem, uint32_t* len); +static void OJPEGWriteStreamDri(TIFF* tif, void** mem, uint32_t* len); +static void OJPEGWriteStreamSof(TIFF* tif, void** mem, uint32_t* len); +static void OJPEGWriteStreamSos(TIFF* tif, void** mem, uint32_t* len); +static int OJPEGWriteStreamCompressed(TIFF* tif, void** mem, uint32_t* len); +static void OJPEGWriteStreamRst(TIFF* tif, void** mem, uint32_t* len); +static void OJPEGWriteStreamEoi(TIFF* tif, void** mem, uint32_t* len); #ifdef LIBJPEG_ENCAP_EXTERNAL extern int jpeg_create_decompress_encap(OJPEGState* sp, jpeg_decompress_struct* cinfo); -extern int jpeg_read_header_encap(OJPEGState* sp, jpeg_decompress_struct* cinfo, uint8 require_image); +extern int jpeg_read_header_encap(OJPEGState* sp, jpeg_decompress_struct* cinfo, uint8_t require_image); extern int jpeg_start_decompress_encap(OJPEGState* sp, jpeg_decompress_struct* cinfo); -extern int jpeg_read_scanlines_encap(OJPEGState* sp, jpeg_decompress_struct* cinfo, void* scanlines, uint32 max_lines); -extern int jpeg_read_raw_data_encap(OJPEGState* sp, jpeg_decompress_struct* cinfo, void* data, uint32 max_lines); +extern int jpeg_read_scanlines_encap(OJPEGState* sp, jpeg_decompress_struct* cinfo, void* scanlines, uint32_t max_lines); +extern int jpeg_read_raw_data_encap(OJPEGState* sp, jpeg_decompress_struct* cinfo, void* data, uint32_t max_lines); extern void jpeg_encap_unwind(TIFF* tif); #else static int jpeg_create_decompress_encap(OJPEGState* sp, jpeg_decompress_struct* j); -static int jpeg_read_header_encap(OJPEGState* sp, jpeg_decompress_struct* cinfo, uint8 require_image); +static int jpeg_read_header_encap(OJPEGState* sp, jpeg_decompress_struct* cinfo, uint8_t require_image); static int jpeg_start_decompress_encap(OJPEGState* sp, jpeg_decompress_struct* cinfo); -static int jpeg_read_scanlines_encap(OJPEGState* sp, jpeg_decompress_struct* cinfo, void* scanlines, uint32 max_lines); -static int jpeg_read_raw_data_encap(OJPEGState* sp, jpeg_decompress_struct* cinfo, void* data, uint32 max_lines); +static int jpeg_read_scanlines_encap(OJPEGState* sp, jpeg_decompress_struct* cinfo, void* scanlines, uint32_t max_lines); +static int jpeg_read_raw_data_encap(OJPEGState* sp, jpeg_decompress_struct* cinfo, void* data, uint32_t max_lines); static void jpeg_encap_unwind(TIFF* tif); #endif @@ -473,7 +473,7 @@ TIFFInitOJPEG(TIFF* tif, int scheme) tif->tif_encodestrip=OJPEGEncode; tif->tif_encodetile=OJPEGEncode; tif->tif_cleanup=OJPEGCleanup; - tif->tif_data=(uint8*)sp; + tif->tif_data=(uint8_t*)sp; /* tif tag methods */ sp->vgetparent=tif->tif_tagmethods.vgetfield; tif->tif_tagmethods.vgetfield=OJPEGVGetField; @@ -492,40 +492,40 @@ TIFFInitOJPEG(TIFF* tif, int scheme) } static int -OJPEGVGetField(TIFF* tif, uint32 tag, va_list ap) +OJPEGVGetField(TIFF* tif, uint32_t tag, va_list ap) { OJPEGState* sp=(OJPEGState*)tif->tif_data; switch(tag) { case TIFFTAG_JPEGIFOFFSET: - *va_arg(ap,uint64*)=(uint64)sp->jpeg_interchange_format; + *va_arg(ap, uint64_t*)=(uint64_t)sp->jpeg_interchange_format; break; case TIFFTAG_JPEGIFBYTECOUNT: - *va_arg(ap,uint64*)=(uint64)sp->jpeg_interchange_format_length; + *va_arg(ap, uint64_t*)=(uint64_t)sp->jpeg_interchange_format_length; break; case TIFFTAG_YCBCRSUBSAMPLING: if (sp->subsamplingcorrect_done==0) OJPEGSubsamplingCorrect(tif); - *va_arg(ap,uint16*)=(uint16)sp->subsampling_hor; - *va_arg(ap,uint16*)=(uint16)sp->subsampling_ver; + *va_arg(ap, uint16_t*)=(uint16_t)sp->subsampling_hor; + *va_arg(ap, uint16_t*)=(uint16_t)sp->subsampling_ver; break; case TIFFTAG_JPEGQTABLES: - *va_arg(ap,uint32*)=(uint32)sp->qtable_offset_count; + *va_arg(ap, uint32_t*)=(uint32_t)sp->qtable_offset_count; *va_arg(ap,const void**)=(const void*)sp->qtable_offset; break; case TIFFTAG_JPEGDCTABLES: - *va_arg(ap,uint32*)=(uint32)sp->dctable_offset_count; + *va_arg(ap, uint32_t*)=(uint32_t)sp->dctable_offset_count; *va_arg(ap,const void**)=(const void*)sp->dctable_offset; break; case TIFFTAG_JPEGACTABLES: - *va_arg(ap,uint32*)=(uint32)sp->actable_offset_count; + *va_arg(ap, uint32_t*)=(uint32_t)sp->actable_offset_count; *va_arg(ap,const void**)=(const void*)sp->actable_offset; break; case TIFFTAG_JPEGPROC: - *va_arg(ap,uint16*)=(uint16)sp->jpeg_proc; + *va_arg(ap, uint16_t*)=(uint16_t)sp->jpeg_proc; break; case TIFFTAG_JPEGRESTARTINTERVAL: - *va_arg(ap,uint16*)=sp->restart_interval; + *va_arg(ap, uint16_t*)=sp->restart_interval; break; default: return (*sp->vgetparent)(tif,tag,ap); @@ -534,32 +534,32 @@ OJPEGVGetField(TIFF* tif, uint32 tag, va_list ap) } static int -OJPEGVSetField(TIFF* tif, uint32 tag, va_list ap) +OJPEGVSetField(TIFF* tif, uint32_t tag, va_list ap) { static const char module[]="OJPEGVSetField"; OJPEGState* sp=(OJPEGState*)tif->tif_data; - uint32 ma; - uint64* mb; - uint32 n; + uint32_t ma; + uint64_t* mb; + uint32_t n; const TIFFField* fip; switch(tag) { case TIFFTAG_JPEGIFOFFSET: - sp->jpeg_interchange_format=(uint64)va_arg(ap,uint64); + sp->jpeg_interchange_format=(uint64_t)va_arg(ap, uint64_t); break; case TIFFTAG_JPEGIFBYTECOUNT: - sp->jpeg_interchange_format_length=(uint64)va_arg(ap,uint64); + sp->jpeg_interchange_format_length=(uint64_t)va_arg(ap, uint64_t); break; case TIFFTAG_YCBCRSUBSAMPLING: sp->subsampling_tag=1; - sp->subsampling_hor=(uint8)va_arg(ap,uint16_vap); - sp->subsampling_ver=(uint8)va_arg(ap,uint16_vap); + sp->subsampling_hor=(uint8_t)va_arg(ap, uint16_vap); + sp->subsampling_ver=(uint8_t)va_arg(ap, uint16_vap); tif->tif_dir.td_ycbcrsubsampling[0]=sp->subsampling_hor; tif->tif_dir.td_ycbcrsubsampling[1]=sp->subsampling_ver; break; case TIFFTAG_JPEGQTABLES: - ma=(uint32)va_arg(ap,uint32); + ma=(uint32_t)va_arg(ap, uint32_t); if (ma!=0) { if (ma>3) @@ -567,14 +567,14 @@ OJPEGVSetField(TIFF* tif, uint32 tag, va_list ap) TIFFErrorExt(tif->tif_clientdata,module,"JpegQTables tag has incorrect count"); return(0); } - sp->qtable_offset_count=(uint8)ma; - mb=(uint64*)va_arg(ap,uint64*); + sp->qtable_offset_count=(uint8_t)ma; + mb=(uint64_t*)va_arg(ap, uint64_t*); for (n=0; n<ma; n++) sp->qtable_offset[n]=mb[n]; } break; case TIFFTAG_JPEGDCTABLES: - ma=(uint32)va_arg(ap,uint32); + ma=(uint32_t)va_arg(ap, uint32_t); if (ma!=0) { if (ma>3) @@ -582,14 +582,14 @@ OJPEGVSetField(TIFF* tif, uint32 tag, va_list ap) TIFFErrorExt(tif->tif_clientdata,module,"JpegDcTables tag has incorrect count"); return(0); } - sp->dctable_offset_count=(uint8)ma; - mb=(uint64*)va_arg(ap,uint64*); + sp->dctable_offset_count=(uint8_t)ma; + mb=(uint64_t*)va_arg(ap, uint64_t*); for (n=0; n<ma; n++) sp->dctable_offset[n]=mb[n]; } break; case TIFFTAG_JPEGACTABLES: - ma=(uint32)va_arg(ap,uint32); + ma=(uint32_t)va_arg(ap, uint32_t); if (ma!=0) { if (ma>3) @@ -597,17 +597,17 @@ OJPEGVSetField(TIFF* tif, uint32 tag, va_list ap) TIFFErrorExt(tif->tif_clientdata,module,"JpegAcTables tag has incorrect count"); return(0); } - sp->actable_offset_count=(uint8)ma; - mb=(uint64*)va_arg(ap,uint64*); + sp->actable_offset_count=(uint8_t)ma; + mb=(uint64_t*)va_arg(ap, uint64_t*); for (n=0; n<ma; n++) sp->actable_offset[n]=mb[n]; } break; case TIFFTAG_JPEGPROC: - sp->jpeg_proc=(uint8)va_arg(ap,uint16_vap); + sp->jpeg_proc=(uint8_t)va_arg(ap, uint16_vap); break; case TIFFTAG_JPEGRESTARTINTERVAL: - sp->restart_interval=(uint16)va_arg(ap,uint16_vap); + sp->restart_interval=(uint16_t)va_arg(ap, uint16_vap); break; default: return (*sp->vsetparent)(tif,tag,ap); @@ -624,38 +624,38 @@ static void OJPEGPrintDir(TIFF* tif, FILE* fd, long flags) { OJPEGState* sp=(OJPEGState*)tif->tif_data; - uint8 m; + uint8_t m; (void)flags; assert(sp!=NULL); if (TIFFFieldSet(tif,FIELD_OJPEG_JPEGINTERCHANGEFORMAT)) - fprintf(fd," JpegInterchangeFormat: " TIFF_UINT64_FORMAT "\n",(TIFF_UINT64_T)sp->jpeg_interchange_format); + fprintf(fd," JpegInterchangeFormat: %" PRIu64 "\n",(uint64_t)sp->jpeg_interchange_format); if (TIFFFieldSet(tif,FIELD_OJPEG_JPEGINTERCHANGEFORMATLENGTH)) - fprintf(fd," JpegInterchangeFormatLength: " TIFF_UINT64_FORMAT "\n",(TIFF_UINT64_T)sp->jpeg_interchange_format_length); + fprintf(fd," JpegInterchangeFormatLength: %" PRIu64 "\n",(uint64_t)sp->jpeg_interchange_format_length); if (TIFFFieldSet(tif,FIELD_OJPEG_JPEGQTABLES)) { fprintf(fd," JpegQTables:"); for (m=0; m<sp->qtable_offset_count; m++) - fprintf(fd," " TIFF_UINT64_FORMAT,(TIFF_UINT64_T)sp->qtable_offset[m]); + fprintf(fd," %" PRIu64,(uint64_t)sp->qtable_offset[m]); fprintf(fd,"\n"); } if (TIFFFieldSet(tif,FIELD_OJPEG_JPEGDCTABLES)) { fprintf(fd," JpegDcTables:"); for (m=0; m<sp->dctable_offset_count; m++) - fprintf(fd," " TIFF_UINT64_FORMAT,(TIFF_UINT64_T)sp->dctable_offset[m]); + fprintf(fd," %" PRIu64,(uint64_t)sp->dctable_offset[m]); fprintf(fd,"\n"); } if (TIFFFieldSet(tif,FIELD_OJPEG_JPEGACTABLES)) { fprintf(fd," JpegAcTables:"); for (m=0; m<sp->actable_offset_count; m++) - fprintf(fd," " TIFF_UINT64_FORMAT,(TIFF_UINT64_T)sp->actable_offset[m]); + fprintf(fd," %" PRIu64,(uint64_t)sp->actable_offset[m]); fprintf(fd,"\n"); } if (TIFFFieldSet(tif,FIELD_OJPEG_JPEGPROC)) - fprintf(fd," JpegProc: %u\n",(unsigned int)sp->jpeg_proc); + fprintf(fd," JpegProc: %"PRIu8"\n", sp->jpeg_proc); if (TIFFFieldSet(tif,FIELD_OJPEG_JPEGRESTARTINTERVAL)) - fprintf(fd," JpegRestartInterval: %u\n",(unsigned int)sp->restart_interval); + fprintf(fd," JpegRestartInterval: %"PRIu16"\n", sp->restart_interval); if (sp->printdir) (*sp->printdir)(tif, fd, flags); } @@ -676,10 +676,10 @@ OJPEGSetupDecode(TIFF* tif) } static int -OJPEGPreDecode(TIFF* tif, uint16 s) +OJPEGPreDecode(TIFF* tif, uint16_t s) { OJPEGState* sp=(OJPEGState*)tif->tif_data; - uint32 m; + uint32_t m; if (sp->subsamplingcorrect_done==0) OJPEGSubsamplingCorrect(tif); if (sp->readheader_done==0) @@ -704,7 +704,7 @@ OJPEGPreDecode(TIFF* tif, uint16 s) } if (sp->writeheader_done==0) { - sp->plane_sample_offset=(uint8)s; + sp->plane_sample_offset=(uint8_t)s; sp->write_cursample=s; sp->write_curstrile=s*tif->tif_dir.td_stripsperimage; if ((sp->in_buffer_file_pos_log==0) || @@ -743,7 +743,7 @@ static int OJPEGPreDecodeSkipRaw(TIFF* tif) { OJPEGState* sp=(OJPEGState*)tif->tif_data; - uint32 m; + uint32_t m; m=sp->lines_per_strile; if (sp->subsampling_convert_state!=0) { @@ -778,7 +778,7 @@ OJPEGPreDecodeSkipScanlines(TIFF* tif) { static const char module[]="OJPEGPreDecodeSkipScanlines"; OJPEGState* sp=(OJPEGState*)tif->tif_data; - uint32 m; + uint32_t m; if (sp->skip_buffer==NULL) { sp->skip_buffer=_TIFFmalloc(sp->bytes_per_line); @@ -797,7 +797,7 @@ OJPEGPreDecodeSkipScanlines(TIFF* tif) } static int -OJPEGDecode(TIFF* tif, uint8* buf, tmsize_t cc, uint16 s) +OJPEGDecode(TIFF* tif, uint8_t* buf, tmsize_t cc, uint16_t s) { static const char module[]="OJPEGDecode"; OJPEGState* sp=(OJPEGState*)tif->tif_data; @@ -825,19 +825,19 @@ OJPEGDecode(TIFF* tif, uint8* buf, tmsize_t cc, uint16 s) } static int -OJPEGDecodeRaw(TIFF* tif, uint8* buf, tmsize_t cc) +OJPEGDecodeRaw(TIFF* tif, uint8_t* buf, tmsize_t cc) { static const char module[]="OJPEGDecodeRaw"; OJPEGState* sp=(OJPEGState*)tif->tif_data; - uint8* m; + uint8_t* m; tmsize_t n; - uint8* oy; - uint8* ocb; - uint8* ocr; - uint8* p; - uint32 q; - uint8* r; - uint8 sx,sy; + uint8_t* oy; + uint8_t* ocb; + uint8_t* ocr; + uint8_t* p; + uint32_t q; + uint8_t* r; + uint8_t sx,sy; if (cc%sp->bytes_per_line!=0) { TIFFErrorExt(tif->tif_clientdata,module,"Fractional scanline not read"); @@ -883,11 +883,11 @@ OJPEGDecodeRaw(TIFF* tif, uint8* buf, tmsize_t cc) } static int -OJPEGDecodeScanlines(TIFF* tif, uint8* buf, tmsize_t cc) +OJPEGDecodeScanlines(TIFF* tif, uint8_t* buf, tmsize_t cc) { static const char module[]="OJPEGDecodeScanlines"; OJPEGState* sp=(OJPEGState*)tif->tif_data; - uint8* m; + uint8_t* m; tmsize_t n; if (cc%sp->bytes_per_line!=0) { @@ -908,7 +908,7 @@ OJPEGDecodeScanlines(TIFF* tif, uint8* buf, tmsize_t cc) } static void -OJPEGPostDecode(TIFF* tif, uint8* buf, tmsize_t cc) +OJPEGPostDecode(TIFF* tif, uint8_t* buf, tmsize_t cc) { OJPEGState* sp=(OJPEGState*)tif->tif_data; (void)buf; @@ -931,7 +931,7 @@ OJPEGSetupEncode(TIFF* tif) } static int -OJPEGPreEncode(TIFF* tif, uint16 s) +OJPEGPreEncode(TIFF* tif, uint16_t s) { static const char module[]="OJPEGPreEncode"; (void)s; @@ -940,7 +940,7 @@ OJPEGPreEncode(TIFF* tif, uint16 s) } static int -OJPEGEncode(TIFF* tif, uint8* buf, tmsize_t cc, uint16 s) +OJPEGEncode(TIFF* tif, uint8_t* buf, tmsize_t cc, uint16_t s) { static const char module[]="OJPEGEncode"; (void)buf; @@ -1010,8 +1010,8 @@ OJPEGSubsamplingCorrect(TIFF* tif) { static const char module[]="OJPEGSubsamplingCorrect"; OJPEGState* sp=(OJPEGState*)tif->tif_data; - uint8 mh; - uint8 mv; + uint8_t mh; + uint8_t mv; assert(sp->subsamplingcorrect_done==0); if ((tif->tif_dir.td_samplesperpixel!=3) || ((tif->tif_dir.td_photometric!=PHOTOMETRIC_YCBCR) && @@ -1039,21 +1039,21 @@ OJPEGSubsamplingCorrect(TIFF* tif) if (((sp->subsampling_hor!=mh) || (sp->subsampling_ver!=mv)) && (sp->subsampling_force_desubsampling_inside_decompression==0)) { if (sp->subsampling_tag==0) - TIFFWarningExt(tif->tif_clientdata,module,"Subsampling tag is not set, yet subsampling inside JPEG data [%d,%d] does not match default values [2,2]; assuming subsampling inside JPEG data is correct",sp->subsampling_hor,sp->subsampling_ver); + TIFFWarningExt(tif->tif_clientdata,module,"Subsampling tag is not set, yet subsampling inside JPEG data [%"PRIu8",%"PRIu8"] does not match default values [2,2]; assuming subsampling inside JPEG data is correct",sp->subsampling_hor,sp->subsampling_ver); else - TIFFWarningExt(tif->tif_clientdata,module,"Subsampling inside JPEG data [%d,%d] does not match subsampling tag values [%d,%d]; assuming subsampling inside JPEG data is correct",sp->subsampling_hor,sp->subsampling_ver,mh,mv); + TIFFWarningExt(tif->tif_clientdata,module,"Subsampling inside JPEG data [%"PRIu8",%"PRIu8"] does not match subsampling tag values [%"PRIu8",%"PRIu8"]; assuming subsampling inside JPEG data is correct",sp->subsampling_hor,sp->subsampling_ver,mh,mv); } if (sp->subsampling_force_desubsampling_inside_decompression!=0) { if (sp->subsampling_tag==0) TIFFWarningExt(tif->tif_clientdata,module,"Subsampling tag is not set, yet subsampling inside JPEG data does not match default values [2,2] (nor any other values allowed in TIFF); assuming subsampling inside JPEG data is correct and desubsampling inside JPEG decompression"); else - TIFFWarningExt(tif->tif_clientdata,module,"Subsampling inside JPEG data does not match subsampling tag values [%d,%d] (nor any other values allowed in TIFF); assuming subsampling inside JPEG data is correct and desubsampling inside JPEG decompression",mh,mv); + TIFFWarningExt(tif->tif_clientdata,module,"Subsampling inside JPEG data does not match subsampling tag values [%"PRIu8",%"PRIu8"] (nor any other values allowed in TIFF); assuming subsampling inside JPEG data is correct and desubsampling inside JPEG decompression",mh,mv); } if (sp->subsampling_force_desubsampling_inside_decompression==0) { if (sp->subsampling_hor<sp->subsampling_ver) - TIFFWarningExt(tif->tif_clientdata,module,"Subsampling values [%d,%d] are not allowed in TIFF",sp->subsampling_hor,sp->subsampling_ver); + TIFFWarningExt(tif->tif_clientdata,module,"Subsampling values [%"PRIu8",%"PRIu8"] are not allowed in TIFF",sp->subsampling_hor,sp->subsampling_ver); } } sp->subsamplingcorrect_done=1; @@ -1077,7 +1077,7 @@ OJPEGReadHeaderInfo(TIFF* tif) { sp->strile_width=sp->image_width; sp->strile_length=tif->tif_dir.td_rowsperstrip; - if( sp->strile_length == (uint32)-1 ) + if( sp->strile_length == (uint32_t)-1 ) sp->strile_length = sp->image_length; sp->strile_length_total=sp->image_length; } @@ -1093,7 +1093,7 @@ OJPEGReadHeaderInfo(TIFF* tif) { if (tif->tif_dir.td_samplesperpixel!=3) { - TIFFErrorExt(tif->tif_clientdata,module,"SamplesPerPixel %d not supported for this compression scheme",sp->samples_per_pixel); + TIFFErrorExt(tif->tif_clientdata,module,"SamplesPerPixel %"PRIu8" not supported for this compression scheme",sp->samples_per_pixel); return(0); } sp->samples_per_pixel=3; @@ -1116,7 +1116,7 @@ OJPEGReadHeaderInfo(TIFF* tif) TIFFErrorExt(tif->tif_clientdata,module,"Incompatible vertical subsampling and image strip/tile length"); return(0); } - sp->restart_interval=(uint16)(((sp->strile_width+sp->subsampling_hor*8-1)/(sp->subsampling_hor*8))*(sp->strile_length/(sp->subsampling_ver*8))); + sp->restart_interval=(uint16_t)(((sp->strile_width + sp->subsampling_hor * 8 - 1) / (sp->subsampling_hor * 8)) * (sp->strile_length / (sp->subsampling_ver * 8))); } if (OJPEGReadHeaderInfoSec(tif)==0) return(0); @@ -1130,15 +1130,15 @@ OJPEGReadHeaderInfo(TIFF* tif) } static int -OJPEGReadSecondarySos(TIFF* tif, uint16 s) +OJPEGReadSecondarySos(TIFF* tif, uint16_t s) { OJPEGState* sp=(OJPEGState*)tif->tif_data; - uint8 m; + uint8_t m; assert(s>0); assert(s<3); assert(sp->sos_end[0].log!=0); assert(sp->sos_end[s].log==0); - sp->plane_sample_offset=(uint8)(s-1); + sp->plane_sample_offset=(uint8_t)(s - 1); while(sp->sos_end[sp->plane_sample_offset].log==0) sp->plane_sample_offset--; sp->in_buffer_source=sp->sos_end[sp->plane_sample_offset].in_buffer_source; @@ -1269,8 +1269,8 @@ OJPEGWriteHeaderInfo(TIFF* tif) { static const char module[]="OJPEGWriteHeaderInfo"; OJPEGState* sp=(OJPEGState*)tif->tif_data; - uint8** m; - uint32 n; + uint8_t** m; + uint32_t n; /* if a previous attempt failed, don't try again */ if (sp->libjpeg_session_active != 0) return 0; @@ -1337,16 +1337,16 @@ OJPEGWriteHeaderInfo(TIFF* tif) sp->subsampling_convert_cbbuf=sp->subsampling_convert_ybuf+sp->subsampling_convert_ybuflen; sp->subsampling_convert_crbuf=sp->subsampling_convert_cbbuf+sp->subsampling_convert_cbuflen; sp->subsampling_convert_ycbcrimagelen=3+sp->subsampling_convert_ylines+2*sp->subsampling_convert_clines; - sp->subsampling_convert_ycbcrimage=_TIFFmalloc(sp->subsampling_convert_ycbcrimagelen*sizeof(uint8*)); + sp->subsampling_convert_ycbcrimage=_TIFFmalloc(sp->subsampling_convert_ycbcrimagelen*sizeof(uint8_t*)); if (sp->subsampling_convert_ycbcrimage==0) { TIFFErrorExt(tif->tif_clientdata,module,"Out of memory"); return(0); } m=sp->subsampling_convert_ycbcrimage; - *m++=(uint8*)(sp->subsampling_convert_ycbcrimage+3); - *m++=(uint8*)(sp->subsampling_convert_ycbcrimage+3+sp->subsampling_convert_ylines); - *m++=(uint8*)(sp->subsampling_convert_ycbcrimage+3+sp->subsampling_convert_ylines+sp->subsampling_convert_clines); + *m++=(uint8_t*)(sp->subsampling_convert_ycbcrimage + 3); + *m++=(uint8_t*)(sp->subsampling_convert_ycbcrimage + 3 + sp->subsampling_convert_ylines); + *m++=(uint8_t*)(sp->subsampling_convert_ycbcrimage + 3 + sp->subsampling_convert_ylines + sp->subsampling_convert_clines); for (n=0; n<sp->subsampling_convert_ylines; n++) *m++=sp->subsampling_convert_ybuf+n*sp->subsampling_convert_ylinelen; for (n=0; n<sp->subsampling_convert_clines; n++) @@ -1373,8 +1373,8 @@ OJPEGWriteHeaderInfo(TIFF* tif) return(0); if(sp->libjpeg_jpeg_decompress_struct.image_width != sp->strile_width ) { TIFFErrorExt(tif->tif_clientdata,module, - "jpeg_start_decompress() returned image_width = %d, " - "expected %d", + "jpeg_start_decompress() returned image_width = %u, " + "expected %"PRIu32, sp->libjpeg_jpeg_decompress_struct.image_width, sp->strile_width); return 0; @@ -1383,7 +1383,7 @@ OJPEGWriteHeaderInfo(TIFF* tif) sp->libjpeg_jpeg_decompress_struct.max_v_samp_factor != sp->subsampling_ver) { TIFFErrorExt(tif->tif_clientdata,module, "jpeg_start_decompress() returned max_h_samp_factor = %d " - "and max_v_samp_factor = %d, expected %d and %d", + "and max_v_samp_factor = %d, expected %"PRIu8" and %"PRIu8, sp->libjpeg_jpeg_decompress_struct.max_h_samp_factor, sp->libjpeg_jpeg_decompress_struct.max_v_samp_factor, sp->subsampling_hor, @@ -1409,9 +1409,9 @@ OJPEGReadHeaderInfoSec(TIFF* tif) { static const char module[]="OJPEGReadHeaderInfoSec"; OJPEGState* sp=(OJPEGState*)tif->tif_data; - uint8 m; - uint16 n; - uint8 o; + uint8_t m; + uint16_t n; + uint8_t o; if (sp->file_size==0) sp->file_size=TIFFGetFileSize(tif); if (sp->jpeg_interchange_format!=0) @@ -1424,7 +1424,7 @@ OJPEGReadHeaderInfoSec(TIFF* tif) else { if ((sp->jpeg_interchange_format_length==0) || - (sp->jpeg_interchange_format > TIFF_UINT64_MAX - sp->jpeg_interchange_format_length) || + (sp->jpeg_interchange_format > UINT64_MAX - sp->jpeg_interchange_format_length) || (sp->jpeg_interchange_format+sp->jpeg_interchange_format_length>sp->file_size)) sp->jpeg_interchange_format_length=sp->file_size-sp->jpeg_interchange_format; } @@ -1508,7 +1508,7 @@ OJPEGReadHeaderInfoSec(TIFF* tif) return(0); break; default: - TIFFErrorExt(tif->tif_clientdata,module,"Unknown marker type %d in JPEG data",m); + TIFFErrorExt(tif->tif_clientdata,module,"Unknown marker type %"PRIu8" in JPEG data", m); return(0); } } while(m!=JPEG_MARKER_SOS); @@ -1544,7 +1544,7 @@ OJPEGReadHeaderInfoSecStreamDri(TIFF* tif) occurred so far */ static const char module[]="OJPEGReadHeaderInfoSecStreamDri"; OJPEGState* sp=(OJPEGState*)tif->tif_data; - uint16 m; + uint16_t m; if (OJPEGReadWord(sp,&m)==0) return(0); if (m!=4) @@ -1564,10 +1564,10 @@ OJPEGReadHeaderInfoSecStreamDqt(TIFF* tif) /* this is a table marker, and it is to be saved as a whole for exact pushing on the jpeg stream later on */ static const char module[]="OJPEGReadHeaderInfoSecStreamDqt"; OJPEGState* sp=(OJPEGState*)tif->tif_data; - uint16 m; - uint32 na; - uint8* nb; - uint8 o; + uint16_t m; + uint32_t na; + uint8_t* nb; + uint8_t o; if (OJPEGReadWord(sp,&m)==0) return(0); if (m<=2) @@ -1588,23 +1588,23 @@ OJPEGReadHeaderInfoSecStreamDqt(TIFF* tif) TIFFErrorExt(tif->tif_clientdata,module,"Corrupt DQT marker in JPEG data"); return(0); } - na=sizeof(uint32)+69; + na= sizeof(uint32_t) + 69; nb=_TIFFmalloc(na); if (nb==0) { TIFFErrorExt(tif->tif_clientdata,module,"Out of memory"); return(0); } - *(uint32*)nb=na; - nb[sizeof(uint32)]=255; - nb[sizeof(uint32)+1]=JPEG_MARKER_DQT; - nb[sizeof(uint32)+2]=0; - nb[sizeof(uint32)+3]=67; - if (OJPEGReadBlock(sp,65,&nb[sizeof(uint32)+4])==0) { + *(uint32_t*)nb=na; + nb[sizeof(uint32_t)]=255; + nb[sizeof(uint32_t) + 1]=JPEG_MARKER_DQT; + nb[sizeof(uint32_t) + 2]=0; + nb[sizeof(uint32_t) + 3]=67; + if (OJPEGReadBlock(sp,65,&nb[sizeof(uint32_t) + 4]) == 0) { _TIFFfree(nb); return(0); } - o=nb[sizeof(uint32)+4]&15; + o= nb[sizeof(uint32_t) + 4] & 15; if (3<o) { TIFFErrorExt(tif->tif_clientdata,module,"Corrupt DQT marker in JPEG data"); @@ -1627,10 +1627,10 @@ OJPEGReadHeaderInfoSecStreamDht(TIFF* tif) /* TODO: the following assumes there is only one table in this marker... but i'm not quite sure that assumption is guaranteed correct */ static const char module[]="OJPEGReadHeaderInfoSecStreamDht"; OJPEGState* sp=(OJPEGState*)tif->tif_data; - uint16 m; - uint32 na; - uint8* nb; - uint8 o; + uint16_t m; + uint32_t na; + uint8_t* nb; + uint8_t o; if (OJPEGReadWord(sp,&m)==0) return(0); if (m<=2) @@ -1645,23 +1645,23 @@ OJPEGReadHeaderInfoSecStreamDht(TIFF* tif) } else { - na=sizeof(uint32)+2+m; + na= sizeof(uint32_t) + 2 + m; nb=_TIFFmalloc(na); if (nb==0) { TIFFErrorExt(tif->tif_clientdata,module,"Out of memory"); return(0); } - *(uint32*)nb=na; - nb[sizeof(uint32)]=255; - nb[sizeof(uint32)+1]=JPEG_MARKER_DHT; - nb[sizeof(uint32)+2]=(m>>8); - nb[sizeof(uint32)+3]=(m&255); - if (OJPEGReadBlock(sp,m-2,&nb[sizeof(uint32)+4])==0) { + *(uint32_t*)nb=na; + nb[sizeof(uint32_t)]=255; + nb[sizeof(uint32_t) + 1]=JPEG_MARKER_DHT; + nb[sizeof(uint32_t) + 2]=(m >> 8); + nb[sizeof(uint32_t) + 3]=(m & 255); + if (OJPEGReadBlock(sp,m-2,&nb[sizeof(uint32_t) + 4]) == 0) { _TIFFfree(nb); return(0); } - o=nb[sizeof(uint32)+4]; + o=nb[sizeof(uint32_t) + 4]; if ((o&240)==0) { if (3<o) @@ -1698,16 +1698,16 @@ OJPEGReadHeaderInfoSecStreamDht(TIFF* tif) } static int -OJPEGReadHeaderInfoSecStreamSof(TIFF* tif, uint8 marker_id) +OJPEGReadHeaderInfoSecStreamSof(TIFF* tif, uint8_t marker_id) { /* this marker needs to be checked, and part of its data needs to be saved for regeneration later on */ static const char module[]="OJPEGReadHeaderInfoSecStreamSof"; OJPEGState* sp=(OJPEGState*)tif->tif_data; - uint16 m; - uint16 n; - uint8 o; - uint16 p; - uint16 q; + uint16_t m; + uint16_t n; + uint8_t o; + uint16_t p; + uint16_t q; if (sp->sof_log!=0) { TIFFErrorExt(tif->tif_clientdata,module,"Corrupt JPEG data"); @@ -1757,7 +1757,7 @@ OJPEGReadHeaderInfoSecStreamSof(TIFF* tif, uint8 marker_id) /* Y: Number of lines */ if (OJPEGReadWord(sp,&p)==0) return(0); - if (((uint32)p<sp->image_length) && ((uint32)p<sp->strile_length_total)) + if (((uint32_t)p < sp->image_length) && ((uint32_t)p < sp->strile_length_total)) { TIFFErrorExt(tif->tif_clientdata,module,"JPEG compressed data indicates unexpected height"); return(0); @@ -1766,12 +1766,12 @@ OJPEGReadHeaderInfoSecStreamSof(TIFF* tif, uint8 marker_id) /* X: Number of samples per line */ if (OJPEGReadWord(sp,&p)==0) return(0); - if (((uint32)p<sp->image_width) && ((uint32)p<sp->strile_width)) + if (((uint32_t)p < sp->image_width) && ((uint32_t)p < sp->strile_width)) { TIFFErrorExt(tif->tif_clientdata,module,"JPEG compressed data indicates unexpected width"); return(0); } - if ((uint32)p>sp->strile_width) + if ((uint32_t)p > sp->strile_width) { TIFFErrorExt(tif->tif_clientdata,module,"JPEG compressed data image width exceeds expected image width"); return(0); @@ -1855,9 +1855,9 @@ OJPEGReadHeaderInfoSecStreamSos(TIFF* tif) /* this marker needs to be checked, and part of its data needs to be saved for regeneration later on */ static const char module[]="OJPEGReadHeaderInfoSecStreamSos"; OJPEGState* sp=(OJPEGState*)tif->tif_data; - uint16 m; - uint8 n; - uint8 o; + uint16_t m; + uint8_t n; + uint8_t o; assert(sp->subsamplingcorrect==0); if (sp->sof_log==0) { @@ -1902,11 +1902,11 @@ OJPEGReadHeaderInfoSecTablesQTable(TIFF* tif) { static const char module[]="OJPEGReadHeaderInfoSecTablesQTable"; OJPEGState* sp=(OJPEGState*)tif->tif_data; - uint8 m; - uint8 n; - uint32 oa; - uint8* ob; - uint32 p; + uint8_t m; + uint8_t n; + uint32_t oa; + uint8_t* ob; + uint32_t p; if (sp->qtable_offset[0]==0) { TIFFErrorExt(tif->tif_clientdata,module,"Missing JPEG tables"); @@ -1925,21 +1925,21 @@ OJPEGReadHeaderInfoSecTablesQTable(TIFF* tif) return(0); } } - oa=sizeof(uint32)+69; + oa= sizeof(uint32_t) + 69; ob=_TIFFmalloc(oa); if (ob==0) { TIFFErrorExt(tif->tif_clientdata,module,"Out of memory"); return(0); } - *(uint32*)ob=oa; - ob[sizeof(uint32)]=255; - ob[sizeof(uint32)+1]=JPEG_MARKER_DQT; - ob[sizeof(uint32)+2]=0; - ob[sizeof(uint32)+3]=67; - ob[sizeof(uint32)+4]=m; + *(uint32_t*)ob=oa; + ob[sizeof(uint32_t)]=255; + ob[sizeof(uint32_t) + 1]=JPEG_MARKER_DQT; + ob[sizeof(uint32_t) + 2]=0; + ob[sizeof(uint32_t) + 3]=67; + ob[sizeof(uint32_t) + 4]=m; TIFFSeekFile(tif,sp->qtable_offset[m],SEEK_SET); - p=(uint32)TIFFReadFile(tif,&ob[sizeof(uint32)+5],64); + p=(uint32_t)TIFFReadFile(tif, &ob[sizeof(uint32_t) + 5], 64); if (p!=64) { _TIFFfree(ob); @@ -1961,13 +1961,13 @@ OJPEGReadHeaderInfoSecTablesDcTable(TIFF* tif) { static const char module[]="OJPEGReadHeaderInfoSecTablesDcTable"; OJPEGState* sp=(OJPEGState*)tif->tif_data; - uint8 m; - uint8 n; - uint8 o[16]; - uint32 p; - uint32 q; - uint32 ra; - uint8* rb; + uint8_t m; + uint8_t n; + uint8_t o[16]; + uint32_t p; + uint32_t q; + uint32_t ra; + uint8_t* rb; if (sp->dctable_offset[0]==0) { TIFFErrorExt(tif->tif_clientdata,module,"Missing JPEG tables"); @@ -1987,28 +1987,28 @@ OJPEGReadHeaderInfoSecTablesDcTable(TIFF* tif) } } TIFFSeekFile(tif,sp->dctable_offset[m],SEEK_SET); - p=(uint32)TIFFReadFile(tif,o,16); + p=(uint32_t)TIFFReadFile(tif, o, 16); if (p!=16) return(0); q=0; for (n=0; n<16; n++) q+=o[n]; - ra=sizeof(uint32)+21+q; + ra= sizeof(uint32_t) + 21 + q; rb=_TIFFmalloc(ra); if (rb==0) { TIFFErrorExt(tif->tif_clientdata,module,"Out of memory"); return(0); } - *(uint32*)rb=ra; - rb[sizeof(uint32)]=255; - rb[sizeof(uint32)+1]=JPEG_MARKER_DHT; - rb[sizeof(uint32)+2]=(uint8)((19+q)>>8); - rb[sizeof(uint32)+3]=((19+q)&255); - rb[sizeof(uint32)+4]=m; + *(uint32_t*)rb=ra; + rb[sizeof(uint32_t)]=255; + rb[sizeof(uint32_t) + 1]=JPEG_MARKER_DHT; + rb[sizeof(uint32_t) + 2]=(uint8_t)((19 + q) >> 8); + rb[sizeof(uint32_t) + 3]=((19 + q) & 255); + rb[sizeof(uint32_t) + 4]=m; for (n=0; n<16; n++) - rb[sizeof(uint32)+5+n]=o[n]; - p=(uint32)TIFFReadFile(tif,&(rb[sizeof(uint32)+21]),q); + rb[sizeof(uint32_t) + 5 + n]=o[n]; + p=(uint32_t)TIFFReadFile(tif, &(rb[sizeof(uint32_t) + 21]), q); if (p!=q) { _TIFFfree(rb); @@ -2030,13 +2030,13 @@ OJPEGReadHeaderInfoSecTablesAcTable(TIFF* tif) { static const char module[]="OJPEGReadHeaderInfoSecTablesAcTable"; OJPEGState* sp=(OJPEGState*)tif->tif_data; - uint8 m; - uint8 n; - uint8 o[16]; - uint32 p; - uint32 q; - uint32 ra; - uint8* rb; + uint8_t m; + uint8_t n; + uint8_t o[16]; + uint32_t p; + uint32_t q; + uint32_t ra; + uint8_t* rb; if (sp->actable_offset[0]==0) { TIFFErrorExt(tif->tif_clientdata,module,"Missing JPEG tables"); @@ -2056,28 +2056,28 @@ OJPEGReadHeaderInfoSecTablesAcTable(TIFF* tif) } } TIFFSeekFile(tif,sp->actable_offset[m],SEEK_SET); - p=(uint32)TIFFReadFile(tif,o,16); + p=(uint32_t)TIFFReadFile(tif, o, 16); if (p!=16) return(0); q=0; for (n=0; n<16; n++) q+=o[n]; - ra=sizeof(uint32)+21+q; + ra= sizeof(uint32_t) + 21 + q; rb=_TIFFmalloc(ra); if (rb==0) { TIFFErrorExt(tif->tif_clientdata,module,"Out of memory"); return(0); } - *(uint32*)rb=ra; - rb[sizeof(uint32)]=255; - rb[sizeof(uint32)+1]=JPEG_MARKER_DHT; - rb[sizeof(uint32)+2]=(uint8)((19+q)>>8); - rb[sizeof(uint32)+3]=((19+q)&255); - rb[sizeof(uint32)+4]=(16|m); + *(uint32_t*)rb=ra; + rb[sizeof(uint32_t)]=255; + rb[sizeof(uint32_t) + 1]=JPEG_MARKER_DHT; + rb[sizeof(uint32_t) + 2]=(uint8_t)((19 + q) >> 8); + rb[sizeof(uint32_t) + 3]=((19 + q) & 255); + rb[sizeof(uint32_t) + 4]=(16 | m); for (n=0; n<16; n++) - rb[sizeof(uint32)+5+n]=o[n]; - p=(uint32)TIFFReadFile(tif,&(rb[sizeof(uint32)+21]),q); + rb[sizeof(uint32_t) + 5 + n]=o[n]; + p=(uint32_t)TIFFReadFile(tif, &(rb[sizeof(uint32_t) + 21]), q); if (p!=q) { _TIFFfree(rb); @@ -2097,7 +2097,7 @@ OJPEGReadHeaderInfoSecTablesAcTable(TIFF* tif) static int OJPEGReadBufferFill(OJPEGState* sp) { - uint16 m; + uint16_t m; tmsize_t n; /* TODO: double-check: when subsamplingcorrect is set, no call to TIFFErrorExt or TIFFWarningExt should be made * in any other case, seek or read errors should be passed through */ @@ -2111,16 +2111,16 @@ OJPEGReadBufferFill(OJPEGState* sp) sp->in_buffer_file_pos_log=1; } m=OJPEG_BUFFER; - if ((uint64)m>sp->in_buffer_file_togo) - m=(uint16)sp->in_buffer_file_togo; + if ((uint64_t)m > sp->in_buffer_file_togo) + m=(uint16_t)sp->in_buffer_file_togo; n=TIFFReadFile(sp->tif,sp->in_buffer,(tmsize_t)m); if (n==0) return(0); assert(n>0); assert(n<=OJPEG_BUFFER); assert(n<65536); - assert((uint64)n<=sp->in_buffer_file_togo); - m=(uint16)n; + assert((uint64_t)n <= sp->in_buffer_file_togo); + m=(uint16_t)n; sp->in_buffer_togo=m; sp->in_buffer_cur=sp->in_buffer; sp->in_buffer_file_togo-=m; @@ -2152,7 +2152,7 @@ OJPEGReadBufferFill(OJPEGState* sp) return 0; if (sp->in_buffer_file_pos!=0) { - uint64 bytecount = TIFFGetStrileByteCountWithErr(sp->tif, sp->in_buffer_next_strile, &err); + uint64_t bytecount = TIFFGetStrileByteCountWithErr(sp->tif, sp->in_buffer_next_strile, &err); if( err ) return 0; if (sp->in_buffer_file_pos>=sp->file_size) @@ -2164,7 +2164,7 @@ OJPEGReadBufferFill(OJPEGState* sp) sp->in_buffer_file_togo=bytecount; if (sp->in_buffer_file_togo==0) sp->in_buffer_file_pos=0; - else if (sp->in_buffer_file_pos > TIFF_UINT64_MAX - sp->in_buffer_file_togo || + else if (sp->in_buffer_file_pos > UINT64_MAX - sp->in_buffer_file_togo || sp->in_buffer_file_pos+sp->in_buffer_file_togo>sp->file_size) sp->in_buffer_file_togo=sp->file_size-sp->in_buffer_file_pos; } @@ -2180,7 +2180,7 @@ OJPEGReadBufferFill(OJPEGState* sp) } static int -OJPEGReadByte(OJPEGState* sp, uint8* byte) +OJPEGReadByte(OJPEGState* sp, uint8_t* byte) { if (sp->in_buffer_togo==0) { @@ -2195,7 +2195,7 @@ OJPEGReadByte(OJPEGState* sp, uint8* byte) } static int -OJPEGReadBytePeek(OJPEGState* sp, uint8* byte) +OJPEGReadBytePeek(OJPEGState* sp, uint8_t* byte) { if (sp->in_buffer_togo==0) { @@ -2216,9 +2216,9 @@ OJPEGReadByteAdvance(OJPEGState* sp) } static int -OJPEGReadWord(OJPEGState* sp, uint16* word) +OJPEGReadWord(OJPEGState* sp, uint16_t* word) { - uint8 m; + uint8_t m; if (OJPEGReadByte(sp,&m)==0) return(0); *word=(m<<8); @@ -2229,11 +2229,11 @@ OJPEGReadWord(OJPEGState* sp, uint16* word) } static int -OJPEGReadBlock(OJPEGState* sp, uint16 len, void* mem) +OJPEGReadBlock(OJPEGState* sp, uint16_t len, void* mem) { - uint16 mlen; - uint8* mmem; - uint16 n; + uint16_t mlen; + uint8_t* mmem; + uint16_t n; assert(len>0); mlen=len; mmem=mem; @@ -2258,10 +2258,10 @@ OJPEGReadBlock(OJPEGState* sp, uint16 len, void* mem) } static void -OJPEGReadSkip(OJPEGState* sp, uint16 len) +OJPEGReadSkip(OJPEGState* sp, uint16_t len) { - uint16 m; - uint16 n; + uint16_t m; + uint16_t n; m=len; n=m; if (n>sp->in_buffer_togo) @@ -2273,8 +2273,8 @@ OJPEGReadSkip(OJPEGState* sp, uint16 len) { assert(sp->in_buffer_togo==0); n=m; - if ((uint64)n>sp->in_buffer_file_togo) - n=(uint16)sp->in_buffer_file_togo; + if ((uint64_t)n > sp->in_buffer_file_togo) + n=(uint16_t)sp->in_buffer_file_togo; sp->in_buffer_file_pos+=n; sp->in_buffer_file_togo-=n; sp->in_buffer_file_pos_log=0; @@ -2288,7 +2288,7 @@ OJPEGReadSkip(OJPEGState* sp, uint16 len) } static int -OJPEGWriteStream(TIFF* tif, void** mem, uint32* len) +OJPEGWriteStream(TIFF* tif, void** mem, uint32_t* len) { OJPEGState* sp=(OJPEGState*)tif->tif_data; *len=0; @@ -2361,7 +2361,7 @@ OJPEGWriteStream(TIFF* tif, void** mem, uint32* len) } static void -OJPEGWriteStreamSoi(TIFF* tif, void** mem, uint32* len) +OJPEGWriteStreamSoi(TIFF* tif, void** mem, uint32_t* len) { OJPEGState* sp=(OJPEGState*)tif->tif_data; assert(OJPEG_BUFFER>=2); @@ -2373,43 +2373,43 @@ OJPEGWriteStreamSoi(TIFF* tif, void** mem, uint32* len) } static void -OJPEGWriteStreamQTable(TIFF* tif, uint8 table_index, void** mem, uint32* len) +OJPEGWriteStreamQTable(TIFF* tif, uint8_t table_index, void** mem, uint32_t* len) { OJPEGState* sp=(OJPEGState*)tif->tif_data; if (sp->qtable[table_index]!=0) { - *mem=(void*)(sp->qtable[table_index]+sizeof(uint32)); - *len=*((uint32*)sp->qtable[table_index])-sizeof(uint32); + *mem=(void*)(sp->qtable[table_index]+sizeof(uint32_t)); + *len= *((uint32_t*)sp->qtable[table_index]) - sizeof(uint32_t); } sp->out_state++; } static void -OJPEGWriteStreamDcTable(TIFF* tif, uint8 table_index, void** mem, uint32* len) +OJPEGWriteStreamDcTable(TIFF* tif, uint8_t table_index, void** mem, uint32_t* len) { OJPEGState* sp=(OJPEGState*)tif->tif_data; if (sp->dctable[table_index]!=0) { - *mem=(void*)(sp->dctable[table_index]+sizeof(uint32)); - *len=*((uint32*)sp->dctable[table_index])-sizeof(uint32); + *mem=(void*)(sp->dctable[table_index]+sizeof(uint32_t)); + *len= *((uint32_t*)sp->dctable[table_index]) - sizeof(uint32_t); } sp->out_state++; } static void -OJPEGWriteStreamAcTable(TIFF* tif, uint8 table_index, void** mem, uint32* len) +OJPEGWriteStreamAcTable(TIFF* tif, uint8_t table_index, void** mem, uint32_t* len) { OJPEGState* sp=(OJPEGState*)tif->tif_data; if (sp->actable[table_index]!=0) { - *mem=(void*)(sp->actable[table_index]+sizeof(uint32)); - *len=*((uint32*)sp->actable[table_index])-sizeof(uint32); + *mem=(void*)(sp->actable[table_index]+sizeof(uint32_t)); + *len= *((uint32_t*)sp->actable[table_index]) - sizeof(uint32_t); } sp->out_state++; } static void -OJPEGWriteStreamDri(TIFF* tif, void** mem, uint32* len) +OJPEGWriteStreamDri(TIFF* tif, void** mem, uint32_t* len) { OJPEGState* sp=(OJPEGState*)tif->tif_data; assert(OJPEG_BUFFER>=6); @@ -2428,10 +2428,10 @@ OJPEGWriteStreamDri(TIFF* tif, void** mem, uint32* len) } static void -OJPEGWriteStreamSof(TIFF* tif, void** mem, uint32* len) +OJPEGWriteStreamSof(TIFF* tif, void** mem, uint32_t* len) { OJPEGState* sp=(OJPEGState*)tif->tif_data; - uint8 m; + uint8_t m; assert(OJPEG_BUFFER>=2+8+sp->samples_per_pixel_per_plane*3); assert(255>=8+sp->samples_per_pixel_per_plane*3); sp->out_buffer[0]=255; @@ -2442,10 +2442,10 @@ OJPEGWriteStreamSof(TIFF* tif, void** mem, uint32* len) /* P */ sp->out_buffer[4]=8; /* Y */ - sp->out_buffer[5]=(uint8)(sp->sof_y>>8); + sp->out_buffer[5]=(uint8_t)(sp->sof_y >> 8); sp->out_buffer[6]=(sp->sof_y&255); /* X */ - sp->out_buffer[7]=(uint8)(sp->sof_x>>8); + sp->out_buffer[7]=(uint8_t)(sp->sof_x >> 8); sp->out_buffer[8]=(sp->sof_x&255); /* Nf */ sp->out_buffer[9]=sp->samples_per_pixel_per_plane; @@ -2464,10 +2464,10 @@ OJPEGWriteStreamSof(TIFF* tif, void** mem, uint32* len) } static void -OJPEGWriteStreamSos(TIFF* tif, void** mem, uint32* len) +OJPEGWriteStreamSos(TIFF* tif, void** mem, uint32_t* len) { OJPEGState* sp=(OJPEGState*)tif->tif_data; - uint8 m; + uint8_t m; assert(OJPEG_BUFFER>=2+6+sp->samples_per_pixel_per_plane*2); assert(255>=6+sp->samples_per_pixel_per_plane*2); sp->out_buffer[0]=255; @@ -2496,7 +2496,7 @@ OJPEGWriteStreamSos(TIFF* tif, void** mem, uint32* len) } static int -OJPEGWriteStreamCompressed(TIFF* tif, void** mem, uint32* len) +OJPEGWriteStreamCompressed(TIFF* tif, void** mem, uint32_t* len) { OJPEGState* sp=(OJPEGState*)tif->tif_data; if (sp->in_buffer_togo==0) @@ -2529,7 +2529,7 @@ OJPEGWriteStreamCompressed(TIFF* tif, void** mem, uint32* len) } static void -OJPEGWriteStreamRst(TIFF* tif, void** mem, uint32* len) +OJPEGWriteStreamRst(TIFF* tif, void** mem, uint32_t* len) { OJPEGState* sp=(OJPEGState*)tif->tif_data; assert(OJPEG_BUFFER>=2); @@ -2544,7 +2544,7 @@ OJPEGWriteStreamRst(TIFF* tif, void** mem, uint32* len) } static void -OJPEGWriteStreamEoi(TIFF* tif, void** mem, uint32* len) +OJPEGWriteStreamEoi(TIFF* tif, void** mem, uint32_t* len) { OJPEGState* sp=(OJPEGState*)tif->tif_data; assert(OJPEG_BUFFER>=2); @@ -2569,7 +2569,7 @@ jpeg_create_decompress_encap(OJPEGState* sp, jpeg_decompress_struct* cinfo) #ifndef LIBJPEG_ENCAP_EXTERNAL static int -jpeg_read_header_encap(OJPEGState* sp, jpeg_decompress_struct* cinfo, uint8 require_image) +jpeg_read_header_encap(OJPEGState* sp, jpeg_decompress_struct* cinfo, uint8_t require_image) { if( SETJMP(sp->exit_jmpbuf) ) return 0; @@ -2595,7 +2595,7 @@ jpeg_start_decompress_encap(OJPEGState* sp, jpeg_decompress_struct* cinfo) #ifndef LIBJPEG_ENCAP_EXTERNAL static int -jpeg_read_scanlines_encap(OJPEGState* sp, jpeg_decompress_struct* cinfo, void* scanlines, uint32 max_lines) +jpeg_read_scanlines_encap(OJPEGState* sp, jpeg_decompress_struct* cinfo, void* scanlines, uint32_t max_lines) { if( SETJMP(sp->exit_jmpbuf) ) return 0; @@ -2608,7 +2608,7 @@ jpeg_read_scanlines_encap(OJPEGState* sp, jpeg_decompress_struct* cinfo, void* s #ifndef LIBJPEG_ENCAP_EXTERNAL static int -jpeg_read_raw_data_encap(OJPEGState* sp, jpeg_decompress_struct* cinfo, void* data, uint32 max_lines) +jpeg_read_raw_data_encap(OJPEGState* sp, jpeg_decompress_struct* cinfo, void* data, uint32_t max_lines) { if( SETJMP(sp->exit_jmpbuf) ) return 0; @@ -2659,7 +2659,7 @@ OJPEGLibjpegJpegSourceMgrFillInputBuffer(jpeg_decompress_struct* cinfo) TIFF *tif = TIFF_FROM_CINFO(cinfo); OJPEGState* sp=(OJPEGState*)tif->tif_data; void* mem=0; - uint32 len=0U; + uint32_t len=0U; if (OJPEGWriteStream(tif,&mem,&len)==0) { TIFFErrorExt(tif->tif_clientdata,"LibJpeg","Premature end of JPEG data"); diff --git a/tiff/libtiff/tif_open.c b/tiff/libtiff/tif_open.c index 0534773a..eec5469d 100644 --- a/tiff/libtiff/tif_open.c +++ b/tiff/libtiff/tif_open.c @@ -88,19 +88,19 @@ TIFFClientOpen( /* The following are configuration checks. They should be redundant, but should not * compile to any actual code in an optimised release build anyway. If any of them * fail, (makefile-based or other) configuration is not correct */ - assert(sizeof(uint8)==1); - assert(sizeof(int8)==1); - assert(sizeof(uint16)==2); - assert(sizeof(int16)==2); - assert(sizeof(uint32)==4); - assert(sizeof(int32)==4); - assert(sizeof(uint64)==8); - assert(sizeof(int64)==8); + assert(sizeof(uint8_t) == 1); + assert(sizeof(int8_t) == 1); + assert(sizeof(uint16_t) == 2); + assert(sizeof(int16_t) == 2); + assert(sizeof(uint32_t) == 4); + assert(sizeof(int32_t) == 4); + assert(sizeof(uint64_t) == 8); + assert(sizeof(int64_t) == 8); assert(sizeof(tmsize_t)==sizeof(void*)); { union{ - uint8 a8[2]; - uint16 a16; + uint8_t a8[2]; + uint16_t a16; } n; n.a8[0]=1; n.a8[1]=0; @@ -124,10 +124,10 @@ TIFFClientOpen( tif->tif_name = (char *)tif + sizeof (TIFF); strcpy(tif->tif_name, name); tif->tif_mode = m &~ (O_CREAT|O_TRUNC); - tif->tif_curdir = (uint16) -1; /* non-existent directory */ + tif->tif_curdir = (uint16_t) -1; /* non-existent directory */ tif->tif_curoff = 0; - tif->tif_curstrip = (uint32) -1; /* invalid strip */ - tif->tif_row = (uint32) -1; /* read/write pre-increment */ + tif->tif_curstrip = (uint32_t) -1; /* invalid strip */ + tif->tif_row = (uint32_t) -1; /* read/write pre-increment */ tif->tif_clientdata = clientdata; if (!readproc || !writeproc || !seekproc || !closeproc || !sizeproc) { TIFFErrorExt(clientdata, module, @@ -373,11 +373,11 @@ TIFFClientOpen( #endif ) { TIFFErrorExt(tif->tif_clientdata, name, - "Not a TIFF or MDI file, bad magic number %d (0x%x)", + "Not a TIFF or MDI file, bad magic number %"PRIu16" (0x%"PRIx16")", #else ) { TIFFErrorExt(tif->tif_clientdata, name, - "Not a TIFF file, bad magic number %d (0x%x)", + "Not a TIFF file, bad magic number %"PRIu16" (0x%"PRIx16")", #endif tif->tif_header.common.tiff_magic, tif->tif_header.common.tiff_magic); @@ -397,7 +397,7 @@ TIFFClientOpen( if ((tif->tif_header.common.tiff_version != TIFF_VERSION_CLASSIC)&& (tif->tif_header.common.tiff_version != TIFF_VERSION_BIG)) { TIFFErrorExt(tif->tif_clientdata, name, - "Not a TIFF file, bad version number %d (0x%x)", + "Not a TIFF file, bad version number %"PRIu16" (0x%"PRIx16")", tif->tif_header.common.tiff_version, tif->tif_header.common.tiff_version); goto bad; @@ -410,7 +410,7 @@ TIFFClientOpen( } else { - if (!ReadOK(tif, ((uint8*)(&tif->tif_header) + sizeof(TIFFHeaderClassic)), (sizeof(TIFFHeaderBig)-sizeof(TIFFHeaderClassic)))) + if (!ReadOK(tif, ((uint8_t*)(&tif->tif_header) + sizeof(TIFFHeaderClassic)), (sizeof(TIFFHeaderBig) - sizeof(TIFFHeaderClassic)))) { TIFFErrorExt(tif->tif_clientdata, name, "Cannot read TIFF header"); @@ -424,7 +424,7 @@ TIFFClientOpen( if (tif->tif_header.big.tiff_offsetsize != 8) { TIFFErrorExt(tif->tif_clientdata, name, - "Not a TIFF file, bad BigTIFF offsetsize %d (0x%x)", + "Not a TIFF file, bad BigTIFF offsetsize %"PRIu16" (0x%"PRIx16")", tif->tif_header.big.tiff_offsetsize, tif->tif_header.big.tiff_offsetsize); goto bad; @@ -432,7 +432,7 @@ TIFFClientOpen( if (tif->tif_header.big.tiff_unused != 0) { TIFFErrorExt(tif->tif_clientdata, name, - "Not a TIFF file, bad BigTIFF unused %d (0x%x)", + "Not a TIFF file, bad BigTIFF unused %"PRIu16" (0x%"PRIx16")", tif->tif_header.big.tiff_unused, tif->tif_header.big.tiff_unused); goto bad; @@ -600,7 +600,7 @@ TIFFIsTiled(TIFF* tif) /* * Return current row being read/written. */ -uint32 +uint32_t TIFFCurrentRow(TIFF* tif) { return (tif->tif_row); @@ -609,7 +609,7 @@ TIFFCurrentRow(TIFF* tif) /* * Return index of the current directory. */ -uint16 +uint16_t TIFFCurrentDirectory(TIFF* tif) { return (tif->tif_curdir); @@ -618,7 +618,7 @@ TIFFCurrentDirectory(TIFF* tif) /* * Return current strip. */ -uint32 +uint32_t TIFFCurrentStrip(TIFF* tif) { return (tif->tif_curstrip); @@ -627,7 +627,7 @@ TIFFCurrentStrip(TIFF* tif) /* * Return current tile. */ -uint32 +uint32_t TIFFCurrentTile(TIFF* tif) { return (tif->tif_curtile); diff --git a/tiff/libtiff/tif_packbits.c b/tiff/libtiff/tif_packbits.c index a8f29e87..76569ad7 100644 --- a/tiff/libtiff/tif_packbits.c +++ b/tiff/libtiff/tif_packbits.c @@ -32,11 +32,11 @@ #include <stdio.h> static int -PackBitsPreEncode(TIFF* tif, uint16 s) +PackBitsPreEncode(TIFF* tif, uint16_t s) { (void) s; - tif->tif_data = (uint8*)_TIFFmalloc(sizeof(tmsize_t)); + tif->tif_data = (uint8_t*)_TIFFmalloc(sizeof(tmsize_t)); if (tif->tif_data == NULL) return (0); /* @@ -61,12 +61,12 @@ PackBitsPostEncode(TIFF* tif) * Encode a run of pixels. */ static int -PackBitsEncode(TIFF* tif, uint8* buf, tmsize_t cc, uint16 s) +PackBitsEncode(TIFF* tif, uint8_t* buf, tmsize_t cc, uint16_t s) { unsigned char* bp = (unsigned char*) buf; - uint8* op; - uint8* ep; - uint8* lastliteral; + uint8_t* op; + uint8_t* ep; + uint8_t* lastliteral; long n, slop; int b; enum { BASE, LITERAL, RUN, LITERAL_RUN } state; @@ -114,17 +114,17 @@ PackBitsEncode(TIFF* tif, uint8* buf, tmsize_t cc, uint16 s) if (n > 1) { state = RUN; if (n > 128) { - *op++ = (uint8) -127; - *op++ = (uint8) b; + *op++ = (uint8_t) -127; + *op++ = (uint8_t) b; n -= 128; goto again; } - *op++ = (uint8)(-(n-1)); - *op++ = (uint8) b; + *op++ = (uint8_t)(-(n - 1)); + *op++ = (uint8_t) b; } else { lastliteral = op; *op++ = 0; - *op++ = (uint8) b; + *op++ = (uint8_t) b; state = LITERAL; } break; @@ -132,33 +132,33 @@ PackBitsEncode(TIFF* tif, uint8* buf, tmsize_t cc, uint16 s) if (n > 1) { state = LITERAL_RUN; if (n > 128) { - *op++ = (uint8) -127; - *op++ = (uint8) b; + *op++ = (uint8_t) -127; + *op++ = (uint8_t) b; n -= 128; goto again; } - *op++ = (uint8)(-(n-1)); /* encode run */ - *op++ = (uint8) b; + *op++ = (uint8_t)(-(n - 1)); /* encode run */ + *op++ = (uint8_t) b; } else { /* extend literal */ if (++(*lastliteral) == 127) state = BASE; - *op++ = (uint8) b; + *op++ = (uint8_t) b; } break; case RUN: /* last object was run */ if (n > 1) { if (n > 128) { - *op++ = (uint8) -127; - *op++ = (uint8) b; + *op++ = (uint8_t) -127; + *op++ = (uint8_t) b; n -= 128; goto again; } - *op++ = (uint8)(-(n-1)); - *op++ = (uint8) b; + *op++ = (uint8_t)(-(n - 1)); + *op++ = (uint8_t) b; } else { lastliteral = op; *op++ = 0; - *op++ = (uint8) b; + *op++ = (uint8_t) b; state = LITERAL; } break; @@ -169,7 +169,7 @@ PackBitsEncode(TIFF* tif, uint8* buf, tmsize_t cc, uint16 s) * case we convert literal-run-literal * to a single literal. */ - if (n == 1 && op[-2] == (uint8) -1 && + if (n == 1 && op[-2] == (uint8_t) -1 && *lastliteral < 126) { state = (((*lastliteral) += 2) == 127 ? BASE : LITERAL); @@ -192,7 +192,7 @@ PackBitsEncode(TIFF* tif, uint8* buf, tmsize_t cc, uint16 s) * when it was encoded by strips. */ static int -PackBitsEncodeChunk(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) +PackBitsEncodeChunk(TIFF* tif, uint8_t* bp, tmsize_t cc, uint16_t s) { tmsize_t rowsize = *(tmsize_t*)tif->tif_data; @@ -211,7 +211,7 @@ PackBitsEncodeChunk(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) } static int -PackBitsDecode(TIFF* tif, uint8* op, tmsize_t occ, uint16 s) +PackBitsDecode(TIFF* tif, uint8_t* op, tmsize_t occ, uint16_t s) { static const char module[] = "PackBitsDecode"; char *bp; @@ -238,8 +238,8 @@ PackBitsDecode(TIFF* tif, uint8* op, tmsize_t occ, uint16 s) if( occ < (tmsize_t)n ) { TIFFWarningExt(tif->tif_clientdata, module, - "Discarding %lu bytes to avoid buffer overrun", - (unsigned long) ((tmsize_t)n - occ)); + "Discarding %"TIFF_SSIZE_FORMAT" bytes to avoid buffer overrun", + (tmsize_t)n - occ); n = (long)occ; } if( cc == 0 ) @@ -252,13 +252,13 @@ PackBitsDecode(TIFF* tif, uint8* op, tmsize_t occ, uint16 s) b = *bp++; cc--; while (n-- > 0) - *op++ = (uint8) b; + *op++ = (uint8_t) b; } else { /* copy next n+1 bytes literally */ if (occ < (tmsize_t)(n + 1)) { TIFFWarningExt(tif->tif_clientdata, module, - "Discarding %lu bytes to avoid buffer overrun", - (unsigned long) ((tmsize_t)n - occ + 1)); + "Discarding %"TIFF_SSIZE_FORMAT" bytes to avoid buffer overrun", + (tmsize_t)n - occ + 1); n = (long)occ - 1; } if (cc < (tmsize_t) (n+1)) @@ -272,12 +272,12 @@ PackBitsDecode(TIFF* tif, uint8* op, tmsize_t occ, uint16 s) bp += n; cc -= n; } } - tif->tif_rawcp = (uint8*) bp; + tif->tif_rawcp = (uint8_t*) bp; tif->tif_rawcc = cc; if (occ > 0) { TIFFErrorExt(tif->tif_clientdata, module, - "Not enough data for scanline %lu", - (unsigned long) tif->tif_row); + "Not enough data for scanline %"PRIu32, + tif->tif_row); return (0); } return (1); diff --git a/tiff/libtiff/tif_pixarlog.c b/tiff/libtiff/tif_pixarlog.c index f2912015..87c67097 100644 --- a/tiff/libtiff/tif_pixarlog.c +++ b/tiff/libtiff/tif_pixarlog.c @@ -109,8 +109,8 @@ static float LogK1, LogK2; #define REPEAT(n, op) { int i; i=n; do { i--; op; } while (i>0); } static void -horizontalAccumulateF(uint16 *wp, int n, int stride, float *op, - float *ToLinearF) +horizontalAccumulateF(uint16_t *wp, int n, int stride, float *op, + float *ToLinearF) { register unsigned int cr, cg, cb, ca, mask; register float t0, t1, t2, t3; @@ -172,14 +172,14 @@ horizontalAccumulateF(uint16 *wp, int n, int stride, float *op, } static void -horizontalAccumulate12(uint16 *wp, int n, int stride, int16 *op, - float *ToLinearF) +horizontalAccumulate12(uint16_t *wp, int n, int stride, int16_t *op, + float *ToLinearF) { register unsigned int cr, cg, cb, ca, mask; register float t0, t1, t2, t3; #define SCALE12 2048.0F -#define CLAMP12(t) (((t) < 3071) ? (uint16) (t) : 3071) +#define CLAMP12(t) (((t) < 3071) ? (uint16_t) (t) : 3071) if (n >= stride) { mask = CODE_MASK; @@ -240,8 +240,8 @@ horizontalAccumulate12(uint16 *wp, int n, int stride, int16 *op, } static void -horizontalAccumulate16(uint16 *wp, int n, int stride, uint16 *op, - uint16 *ToLinear16) +horizontalAccumulate16(uint16_t *wp, int n, int stride, uint16_t *op, + uint16_t *ToLinear16) { register unsigned int cr, cg, cb, ca, mask; @@ -292,7 +292,7 @@ horizontalAccumulate16(uint16 *wp, int n, int stride, uint16 *op, * differencing undone. */ static void -horizontalAccumulate11(uint16 *wp, int n, int stride, uint16 *op) +horizontalAccumulate11(uint16_t *wp, int n, int stride, uint16_t *op) { register unsigned int cr, cg, cb, ca, mask; @@ -306,9 +306,9 @@ horizontalAccumulate11(uint16 *wp, int n, int stride, uint16 *op) wp += 3; op += 3; n -= 3; - op[0] = (uint16)((cr += wp[0]) & mask); - op[1] = (uint16)((cg += wp[1]) & mask); - op[2] = (uint16)((cb += wp[2]) & mask); + op[0] = (uint16_t)((cr += wp[0]) & mask); + op[1] = (uint16_t)((cg += wp[1]) & mask); + op[2] = (uint16_t)((cb += wp[2]) & mask); } } else if (stride == 4) { op[0] = wp[0]; op[1] = wp[1]; @@ -319,10 +319,10 @@ horizontalAccumulate11(uint16 *wp, int n, int stride, uint16 *op) wp += 4; op += 4; n -= 4; - op[0] = (uint16)((cr += wp[0]) & mask); - op[1] = (uint16)((cg += wp[1]) & mask); - op[2] = (uint16)((cb += wp[2]) & mask); - op[3] = (uint16)((ca += wp[3]) & mask); + op[0] = (uint16_t)((cr += wp[0]) & mask); + op[1] = (uint16_t)((cg += wp[1]) & mask); + op[2] = (uint16_t)((cb += wp[2]) & mask); + op[3] = (uint16_t)((ca += wp[3]) & mask); } } else { REPEAT(stride, *op = *wp&mask; wp++; op++) @@ -337,8 +337,8 @@ horizontalAccumulate11(uint16 *wp, int n, int stride, uint16 *op) } static void -horizontalAccumulate8(uint16 *wp, int n, int stride, unsigned char *op, - unsigned char *ToLinear8) +horizontalAccumulate8(uint16_t *wp, int n, int stride, unsigned char *op, + unsigned char *ToLinear8) { register unsigned int cr, cg, cb, ca, mask; @@ -386,8 +386,8 @@ horizontalAccumulate8(uint16 *wp, int n, int stride, unsigned char *op, static void -horizontalAccumulate8abgr(uint16 *wp, int n, int stride, unsigned char *op, - unsigned char *ToLinear8) +horizontalAccumulate8abgr(uint16_t *wp, int n, int stride, unsigned char *op, + unsigned char *ToLinear8) { register unsigned int cr, cg, cb, ca, mask; register unsigned char t0, t1, t2, t3; @@ -458,8 +458,8 @@ typedef struct { TIFFPredictorState predict; z_stream stream; tmsize_t tbuf_size; /* only set/used on reading for now */ - uint16 *tbuf; - uint16 stride; + uint16_t *tbuf; + uint16_t stride; int state; int user_datafmt; int quality; @@ -469,11 +469,11 @@ typedef struct { TIFFVSetMethod vsetparent; /* super-class method */ float *ToLinearF; - uint16 *ToLinear16; + uint16_t *ToLinear16; unsigned char *ToLinear8; - uint16 *FromLT2; - uint16 *From14; /* Really for 16-bit data, but we shift down 2 */ - uint16 *From8; + uint16_t *FromLT2; + uint16_t *From14; /* Really for 16-bit data, but we shift down 2 */ + uint16_t *From8; } PixarLogState; @@ -496,11 +496,11 @@ PixarLogMakeTables(PixarLogState *sp) int i, j; double b, c, linstep, v; float *ToLinearF; - uint16 *ToLinear16; + uint16_t *ToLinear16; unsigned char *ToLinear8; - uint16 *FromLT2; - uint16 *From14; /* Really for 16-bit data, but we shift down 2 */ - uint16 *From8; + uint16_t *FromLT2; + uint16_t *From14; /* Really for 16-bit data, but we shift down 2 */ + uint16_t *From8; c = log(RATIO); nlin = (int)(1./c); /* nlin must be an integer */ @@ -511,11 +511,11 @@ PixarLogMakeTables(PixarLogState *sp) LogK1 = (float)(1./c); /* if (v >= 2) token = k1*log(v*k2) */ LogK2 = (float)(1./b); lt2size = (int)(2./linstep) + 1; - FromLT2 = (uint16 *)_TIFFmalloc(lt2size*sizeof(uint16)); - From14 = (uint16 *)_TIFFmalloc(16384*sizeof(uint16)); - From8 = (uint16 *)_TIFFmalloc(256*sizeof(uint16)); + FromLT2 = (uint16_t *)_TIFFmalloc(lt2size * sizeof(uint16_t)); + From14 = (uint16_t *)_TIFFmalloc(16384 * sizeof(uint16_t)); + From8 = (uint16_t *)_TIFFmalloc(256 * sizeof(uint16_t)); ToLinearF = (float *)_TIFFmalloc(TSIZEP1 * sizeof(float)); - ToLinear16 = (uint16 *)_TIFFmalloc(TSIZEP1 * sizeof(uint16)); + ToLinear16 = (uint16_t *)_TIFFmalloc(TSIZEP1 * sizeof(uint16_t)); ToLinear8 = (unsigned char *)_TIFFmalloc(TSIZEP1 * sizeof(unsigned char)); if (FromLT2 == NULL || From14 == NULL || From8 == NULL || ToLinearF == NULL || ToLinear16 == NULL || ToLinear8 == NULL) { @@ -548,7 +548,7 @@ PixarLogMakeTables(PixarLogState *sp) for (i = 0; i < TSIZEP1; i++) { v = ToLinearF[i]*65535.0 + 0.5; - ToLinear16[i] = (v > 65535.0) ? 65535 : (uint16)v; + ToLinear16[i] = (v > 65535.0) ? 65535 : (uint16_t)v; v = ToLinearF[i]*255.0 + 0.5; ToLinear8[i] = (v > 255.0) ? 255 : (unsigned char)v; } @@ -557,7 +557,7 @@ PixarLogMakeTables(PixarLogState *sp) for (i = 0; i < lt2size; i++) { if ((i*linstep)*(i*linstep) > ToLinearF[j]*ToLinearF[j+1]) j++; - FromLT2[i] = (uint16)j; + FromLT2[i] = (uint16_t)j; } /* @@ -569,14 +569,14 @@ PixarLogMakeTables(PixarLogState *sp) for (i = 0; i < 16384; i++) { while ((i/16383.)*(i/16383.) > ToLinearF[j]*ToLinearF[j+1]) j++; - From14[i] = (uint16)j; + From14[i] = (uint16_t)j; } j = 0; for (i = 0; i < 256; i++) { while ((i/255.)*(i/255.) > ToLinearF[j]*ToLinearF[j+1]) j++; - From8[i] = (uint16)j; + From8[i] = (uint16_t)j; } Fltsize = (float)(lt2size/2); @@ -594,8 +594,8 @@ PixarLogMakeTables(PixarLogState *sp) #define DecoderState(tif) ((PixarLogState*) (tif)->tif_data) #define EncoderState(tif) ((PixarLogState*) (tif)->tif_data) -static int PixarLogEncode(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s); -static int PixarLogDecode(TIFF* tif, uint8* op, tmsize_t occ, uint16 s); +static int PixarLogEncode(TIFF* tif, uint8_t* bp, tmsize_t cc, uint16_t s); +static int PixarLogDecode(TIFF* tif, uint8_t* op, tmsize_t occ, uint16_t s); #define PIXARLOGDATAFMT_UNKNOWN -1 @@ -667,7 +667,7 @@ PixarLogSetupDecode(TIFF* tif) TIFFDirectory *td = &tif->tif_dir; PixarLogState* sp = DecoderState(tif); tmsize_t tbuf_size; - uint32 strip_height; + uint32_t strip_height; assert(sp != NULL); @@ -690,12 +690,12 @@ PixarLogSetupDecode(TIFF* tif) sp->stride = (td->td_planarconfig == PLANARCONFIG_CONTIG ? td->td_samplesperpixel : 1); tbuf_size = multiply_ms(multiply_ms(multiply_ms(sp->stride, td->td_imagewidth), - strip_height), sizeof(uint16)); + strip_height), sizeof(uint16_t)); /* add one more stride in case input ends mid-stride */ - tbuf_size = add_ms(tbuf_size, sizeof(uint16) * sp->stride); + tbuf_size = add_ms(tbuf_size, sizeof(uint16_t) * sp->stride); if (tbuf_size == 0) return (0); /* TODO: this is an error return without error report through TIFFErrorExt */ - sp->tbuf = (uint16 *) _TIFFmalloc(tbuf_size); + sp->tbuf = (uint16_t *) _TIFFmalloc(tbuf_size); if (sp->tbuf == NULL) return (0); sp->tbuf_size = tbuf_size; @@ -706,7 +706,7 @@ PixarLogSetupDecode(TIFF* tif) sp->tbuf = NULL; sp->tbuf_size = 0; TIFFErrorExt(tif->tif_clientdata, module, - "PixarLog compression can't handle bits depth/data format combination (depth: %d)", + "PixarLog compression can't handle bits depth/data format combination (depth: %"PRIu16")", td->td_bitspersample); return (0); } @@ -727,7 +727,7 @@ PixarLogSetupDecode(TIFF* tif) * Setup state for decoding a strip. */ static int -PixarLogPreDecode(TIFF* tif, uint16 s) +PixarLogPreDecode(TIFF* tif, uint16_t s) { static const char module[] = "PixarLogPreDecode"; PixarLogState* sp = DecoderState(tif); @@ -749,7 +749,7 @@ PixarLogPreDecode(TIFF* tif, uint16 s) } static int -PixarLogDecode(TIFF* tif, uint8* op, tmsize_t occ, uint16 s) +PixarLogDecode(TIFF* tif, uint8_t* op, tmsize_t occ, uint16_t s) { static const char module[] = "PixarLogDecode"; TIFFDirectory *td = &tif->tif_dir; @@ -757,7 +757,7 @@ PixarLogDecode(TIFF* tif, uint8* op, tmsize_t occ, uint16 s) tmsize_t i; tmsize_t nsamples; int llen; - uint16 *up; + uint16_t *up; switch (sp->user_datafmt) { case PIXARLOGDATAFMT_FLOAT: @@ -766,7 +766,7 @@ PixarLogDecode(TIFF* tif, uint8* op, tmsize_t occ, uint16 s) case PIXARLOGDATAFMT_16BIT: case PIXARLOGDATAFMT_12BITPICIO: case PIXARLOGDATAFMT_11BITLOG: - nsamples = occ / sizeof(uint16); /* XXX uint16 == 16 bits */ + nsamples = occ / sizeof(uint16_t); /* XXX uint16_t == 16 bits */ break; case PIXARLOGDATAFMT_8BIT: case PIXARLOGDATAFMT_8BITABGR: @@ -774,7 +774,7 @@ PixarLogDecode(TIFF* tif, uint8* op, tmsize_t occ, uint16 s) break; default: TIFFErrorExt(tif->tif_clientdata, module, - "%d bit input not supported in PixarLog", + "%"PRIu16" bit input not supported in PixarLog", td->td_bitspersample); return 0; } @@ -792,8 +792,8 @@ PixarLogDecode(TIFF* tif, uint8* op, tmsize_t occ, uint16 s) we need to simplify this code to reflect a ZLib that is likely updated to deal with 8byte memory sizes, though this code will respond appropriately even before we simplify it */ - sp->stream.avail_out = (uInt) (nsamples * sizeof(uint16)); - if (sp->stream.avail_out != nsamples * sizeof(uint16)) + sp->stream.avail_out = (uInt) (nsamples * sizeof(uint16_t)); + if (sp->stream.avail_out != nsamples * sizeof(uint16_t)) { TIFFErrorExt(tif->tif_clientdata, module, "ZLib cannot deal with buffers this size"); return (0); @@ -811,8 +811,8 @@ PixarLogDecode(TIFF* tif, uint8* op, tmsize_t occ, uint16 s) } if (state == Z_DATA_ERROR) { TIFFErrorExt(tif->tif_clientdata, module, - "Decoding error at scanline %lu, %s", - (unsigned long) tif->tif_row, sp->stream.msg ? sp->stream.msg : "(null)"); + "Decoding error at scanline %"PRIu32", %s", + tif->tif_row, sp->stream.msg ? sp->stream.msg : "(null)"); return (0); } if (state != Z_OK) { @@ -825,8 +825,8 @@ PixarLogDecode(TIFF* tif, uint8* op, tmsize_t occ, uint16 s) /* hopefully, we got all the bytes we needed */ if (sp->stream.avail_out != 0) { TIFFErrorExt(tif->tif_clientdata, module, - "Not enough data at scanline %lu (short " TIFF_UINT64_FORMAT " bytes)", - (unsigned long) tif->tif_row, (TIFF_UINT64_T) sp->stream.avail_out); + "Not enough data at scanline %"PRIu32" (short %u bytes)", + tif->tif_row, sp->stream.avail_out); return (0); } @@ -845,8 +845,8 @@ PixarLogDecode(TIFF* tif, uint8* op, tmsize_t occ, uint16 s) */ if (nsamples % llen) { TIFFWarningExt(tif->tif_clientdata, module, - "stride %lu is not a multiple of sample count, " - "%lu, data truncated.", (unsigned long) llen, (unsigned long) nsamples); + "stride %d is not a multiple of sample count, " + "%"TIFF_SSIZE_FORMAT", data truncated.", llen, nsamples); nsamples -= nsamples % llen; } @@ -859,18 +859,18 @@ PixarLogDecode(TIFF* tif, uint8* op, tmsize_t occ, uint16 s) break; case PIXARLOGDATAFMT_16BIT: horizontalAccumulate16(up, llen, sp->stride, - (uint16 *)op, sp->ToLinear16); - op += llen * sizeof(uint16); + (uint16_t *)op, sp->ToLinear16); + op += llen * sizeof(uint16_t); break; case PIXARLOGDATAFMT_12BITPICIO: horizontalAccumulate12(up, llen, sp->stride, - (int16 *)op, sp->ToLinearF); - op += llen * sizeof(int16); + (int16_t *)op, sp->ToLinearF); + op += llen * sizeof(int16_t); break; case PIXARLOGDATAFMT_11BITLOG: horizontalAccumulate11(up, llen, sp->stride, - (uint16 *)op); - op += llen * sizeof(uint16); + (uint16_t *)op); + op += llen * sizeof(uint16_t); break; case PIXARLOGDATAFMT_8BIT: horizontalAccumulate8(up, llen, sp->stride, @@ -884,7 +884,7 @@ PixarLogDecode(TIFF* tif, uint8* op, tmsize_t occ, uint16 s) break; default: TIFFErrorExt(tif->tif_clientdata, module, - "Unsupported bits/sample: %d", + "Unsupported bits/sample: %"PRIu16, td->td_bitspersample); return (0); } @@ -908,16 +908,16 @@ PixarLogSetupEncode(TIFF* tif) sp->stride = (td->td_planarconfig == PLANARCONFIG_CONTIG ? td->td_samplesperpixel : 1); tbuf_size = multiply_ms(multiply_ms(multiply_ms(sp->stride, td->td_imagewidth), - td->td_rowsperstrip), sizeof(uint16)); + td->td_rowsperstrip), sizeof(uint16_t)); if (tbuf_size == 0) return (0); /* TODO: this is an error return without error report through TIFFErrorExt */ - sp->tbuf = (uint16 *) _TIFFmalloc(tbuf_size); + sp->tbuf = (uint16_t *) _TIFFmalloc(tbuf_size); if (sp->tbuf == NULL) return (0); if (sp->user_datafmt == PIXARLOGDATAFMT_UNKNOWN) sp->user_datafmt = PixarLogGuessDataFmt(td); if (sp->user_datafmt == PIXARLOGDATAFMT_UNKNOWN) { - TIFFErrorExt(tif->tif_clientdata, module, "PixarLog compression can't handle %d bit linear encodings", td->td_bitspersample); + TIFFErrorExt(tif->tif_clientdata, module, "PixarLog compression can't handle %"PRIu16" bit linear encodings", td->td_bitspersample); return (0); } @@ -934,7 +934,7 @@ PixarLogSetupEncode(TIFF* tif) * Reset encoding state at the start of a strip. */ static int -PixarLogPreEncode(TIFF* tif, uint16 s) +PixarLogPreEncode(TIFF* tif, uint16_t s) { static const char module[] = "PixarLogPreEncode"; PixarLogState *sp = EncoderState(tif); @@ -956,9 +956,9 @@ PixarLogPreEncode(TIFF* tif, uint16 s) } static void -horizontalDifferenceF(float *ip, int n, int stride, uint16 *wp, uint16 *FromLT2) +horizontalDifferenceF(float *ip, int n, int stride, uint16_t *wp, uint16_t *FromLT2) { - int32 r1, g1, b1, a1, r2, g2, b2, a2, mask; + int32_t r1, g1, b1, a1, r2, g2, b2, a2, mask; float fltsize = Fltsize; #define CLAMP(v) ( (v<(float)0.) ? 0 \ @@ -969,39 +969,39 @@ horizontalDifferenceF(float *ip, int n, int stride, uint16 *wp, uint16 *FromLT2) mask = CODE_MASK; if (n >= stride) { if (stride == 3) { - r2 = wp[0] = (uint16) CLAMP(ip[0]); - g2 = wp[1] = (uint16) CLAMP(ip[1]); - b2 = wp[2] = (uint16) CLAMP(ip[2]); + r2 = wp[0] = (uint16_t) CLAMP(ip[0]); + g2 = wp[1] = (uint16_t) CLAMP(ip[1]); + b2 = wp[2] = (uint16_t) CLAMP(ip[2]); n -= 3; while (n > 0) { n -= 3; wp += 3; ip += 3; - r1 = (int32) CLAMP(ip[0]); wp[0] = (uint16)((r1-r2) & mask); r2 = r1; - g1 = (int32) CLAMP(ip[1]); wp[1] = (uint16)((g1-g2) & mask); g2 = g1; - b1 = (int32) CLAMP(ip[2]); wp[2] = (uint16)((b1-b2) & mask); b2 = b1; + r1 = (int32_t) CLAMP(ip[0]); wp[0] = (uint16_t)((r1 - r2) & mask); r2 = r1; + g1 = (int32_t) CLAMP(ip[1]); wp[1] = (uint16_t)((g1 - g2) & mask); g2 = g1; + b1 = (int32_t) CLAMP(ip[2]); wp[2] = (uint16_t)((b1 - b2) & mask); b2 = b1; } } else if (stride == 4) { - r2 = wp[0] = (uint16) CLAMP(ip[0]); - g2 = wp[1] = (uint16) CLAMP(ip[1]); - b2 = wp[2] = (uint16) CLAMP(ip[2]); - a2 = wp[3] = (uint16) CLAMP(ip[3]); + r2 = wp[0] = (uint16_t) CLAMP(ip[0]); + g2 = wp[1] = (uint16_t) CLAMP(ip[1]); + b2 = wp[2] = (uint16_t) CLAMP(ip[2]); + a2 = wp[3] = (uint16_t) CLAMP(ip[3]); n -= 4; while (n > 0) { n -= 4; wp += 4; ip += 4; - r1 = (int32) CLAMP(ip[0]); wp[0] = (uint16)((r1-r2) & mask); r2 = r1; - g1 = (int32) CLAMP(ip[1]); wp[1] = (uint16)((g1-g2) & mask); g2 = g1; - b1 = (int32) CLAMP(ip[2]); wp[2] = (uint16)((b1-b2) & mask); b2 = b1; - a1 = (int32) CLAMP(ip[3]); wp[3] = (uint16)((a1-a2) & mask); a2 = a1; + r1 = (int32_t) CLAMP(ip[0]); wp[0] = (uint16_t)((r1 - r2) & mask); r2 = r1; + g1 = (int32_t) CLAMP(ip[1]); wp[1] = (uint16_t)((g1 - g2) & mask); g2 = g1; + b1 = (int32_t) CLAMP(ip[2]); wp[2] = (uint16_t)((b1 - b2) & mask); b2 = b1; + a1 = (int32_t) CLAMP(ip[3]); wp[3] = (uint16_t)((a1 - a2) & mask); a2 = a1; } } else { - REPEAT(stride, wp[0] = (uint16) CLAMP(ip[0]); wp++; ip++) + REPEAT(stride, wp[0] = (uint16_t) CLAMP(ip[0]); wp++; ip++) n -= stride; while (n > 0) { REPEAT(stride, - wp[0] = (uint16)(((int32)CLAMP(ip[0])-(int32)CLAMP(ip[-stride])) & mask); + wp[0] = (uint16_t)(((int32_t)CLAMP(ip[0]) - (int32_t)CLAMP(ip[-stride])) & mask); wp++; ip++) n -= stride; } @@ -1010,8 +1010,8 @@ horizontalDifferenceF(float *ip, int n, int stride, uint16 *wp, uint16 *FromLT2) } static void -horizontalDifference16(unsigned short *ip, int n, int stride, - unsigned short *wp, uint16 *From14) +horizontalDifference16(unsigned short *ip, int n, int stride, + unsigned short *wp, uint16_t *From14) { register int r1, g1, b1, a1, r2, g2, b2, a2, mask; @@ -1029,9 +1029,9 @@ horizontalDifference16(unsigned short *ip, int n, int stride, n -= 3; wp += 3; ip += 3; - r1 = CLAMP(ip[0]); wp[0] = (uint16)((r1-r2) & mask); r2 = r1; - g1 = CLAMP(ip[1]); wp[1] = (uint16)((g1-g2) & mask); g2 = g1; - b1 = CLAMP(ip[2]); wp[2] = (uint16)((b1-b2) & mask); b2 = b1; + r1 = CLAMP(ip[0]); wp[0] = (uint16_t)((r1 - r2) & mask); r2 = r1; + g1 = CLAMP(ip[1]); wp[1] = (uint16_t)((g1 - g2) & mask); g2 = g1; + b1 = CLAMP(ip[2]); wp[2] = (uint16_t)((b1 - b2) & mask); b2 = b1; } } else if (stride == 4) { r2 = wp[0] = CLAMP(ip[0]); g2 = wp[1] = CLAMP(ip[1]); @@ -1041,17 +1041,17 @@ horizontalDifference16(unsigned short *ip, int n, int stride, n -= 4; wp += 4; ip += 4; - r1 = CLAMP(ip[0]); wp[0] = (uint16)((r1-r2) & mask); r2 = r1; - g1 = CLAMP(ip[1]); wp[1] = (uint16)((g1-g2) & mask); g2 = g1; - b1 = CLAMP(ip[2]); wp[2] = (uint16)((b1-b2) & mask); b2 = b1; - a1 = CLAMP(ip[3]); wp[3] = (uint16)((a1-a2) & mask); a2 = a1; + r1 = CLAMP(ip[0]); wp[0] = (uint16_t)((r1 - r2) & mask); r2 = r1; + g1 = CLAMP(ip[1]); wp[1] = (uint16_t)((g1 - g2) & mask); g2 = g1; + b1 = CLAMP(ip[2]); wp[2] = (uint16_t)((b1 - b2) & mask); b2 = b1; + a1 = CLAMP(ip[3]); wp[3] = (uint16_t)((a1 - a2) & mask); a2 = a1; } } else { REPEAT(stride, wp[0] = CLAMP(ip[0]); wp++; ip++) n -= stride; while (n > 0) { REPEAT(stride, - wp[0] = (uint16)((CLAMP(ip[0])-CLAMP(ip[-stride])) & mask); + wp[0] = (uint16_t)((CLAMP(ip[0]) - CLAMP(ip[-stride])) & mask); wp++; ip++) n -= stride; } @@ -1061,8 +1061,8 @@ horizontalDifference16(unsigned short *ip, int n, int stride, static void -horizontalDifference8(unsigned char *ip, int n, int stride, - unsigned short *wp, uint16 *From8) +horizontalDifference8(unsigned char *ip, int n, int stride, + unsigned short *wp, uint16_t *From8) { register int r1, g1, b1, a1, r2, g2, b2, a2, mask; @@ -1077,9 +1077,9 @@ horizontalDifference8(unsigned char *ip, int n, int stride, n -= 3; while (n > 0) { n -= 3; - r1 = CLAMP(ip[3]); wp[3] = (uint16)((r1-r2) & mask); r2 = r1; - g1 = CLAMP(ip[4]); wp[4] = (uint16)((g1-g2) & mask); g2 = g1; - b1 = CLAMP(ip[5]); wp[5] = (uint16)((b1-b2) & mask); b2 = b1; + r1 = CLAMP(ip[3]); wp[3] = (uint16_t)((r1 - r2) & mask); r2 = r1; + g1 = CLAMP(ip[4]); wp[4] = (uint16_t)((g1 - g2) & mask); g2 = g1; + b1 = CLAMP(ip[5]); wp[5] = (uint16_t)((b1 - b2) & mask); b2 = b1; wp += 3; ip += 3; } @@ -1089,10 +1089,10 @@ horizontalDifference8(unsigned char *ip, int n, int stride, n -= 4; while (n > 0) { n -= 4; - r1 = CLAMP(ip[4]); wp[4] = (uint16)((r1-r2) & mask); r2 = r1; - g1 = CLAMP(ip[5]); wp[5] = (uint16)((g1-g2) & mask); g2 = g1; - b1 = CLAMP(ip[6]); wp[6] = (uint16)((b1-b2) & mask); b2 = b1; - a1 = CLAMP(ip[7]); wp[7] = (uint16)((a1-a2) & mask); a2 = a1; + r1 = CLAMP(ip[4]); wp[4] = (uint16_t)((r1 - r2) & mask); r2 = r1; + g1 = CLAMP(ip[5]); wp[5] = (uint16_t)((g1 - g2) & mask); g2 = g1; + b1 = CLAMP(ip[6]); wp[6] = (uint16_t)((b1 - b2) & mask); b2 = b1; + a1 = CLAMP(ip[7]); wp[7] = (uint16_t)((a1 - a2) & mask); a2 = a1; wp += 4; ip += 4; } @@ -1101,7 +1101,7 @@ horizontalDifference8(unsigned char *ip, int n, int stride, n -= stride; while (n > 0) { REPEAT(stride, - wp[0] = (uint16)((CLAMP(ip[0])-CLAMP(ip[-stride])) & mask); + wp[0] = (uint16_t)((CLAMP(ip[0]) - CLAMP(ip[-stride])) & mask); wp++; ip++) n -= stride; } @@ -1113,7 +1113,7 @@ horizontalDifference8(unsigned char *ip, int n, int stride, * Encode a chunk of pixels. */ static int -PixarLogEncode(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) +PixarLogEncode(TIFF* tif, uint8_t* bp, tmsize_t cc, uint16_t s) { static const char module[] = "PixarLogEncode"; TIFFDirectory *td = &tif->tif_dir; @@ -1132,7 +1132,7 @@ PixarLogEncode(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) case PIXARLOGDATAFMT_16BIT: case PIXARLOGDATAFMT_12BITPICIO: case PIXARLOGDATAFMT_11BITLOG: - n = cc / sizeof(uint16); /* XXX uint16 == 16 bits */ + n = cc / sizeof(uint16_t); /* XXX uint16_t == 16 bits */ break; case PIXARLOGDATAFMT_8BIT: case PIXARLOGDATAFMT_8BITABGR: @@ -1140,13 +1140,13 @@ PixarLogEncode(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) break; default: TIFFErrorExt(tif->tif_clientdata, module, - "%d bit input not supported in PixarLog", + "%"PRIu16" bit input not supported in PixarLog", td->td_bitspersample); return 0; } llen = sp->stride * td->td_imagewidth; - /* Check against the number of elements (of size uint16) of sp->tbuf */ + /* Check against the number of elements (of size uint16_t) of sp->tbuf */ if( n > ((tmsize_t)td->td_rowsperstrip * llen) ) { TIFFErrorExt(tif->tif_clientdata, module, @@ -1162,9 +1162,9 @@ PixarLogEncode(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) bp += llen * sizeof(float); break; case PIXARLOGDATAFMT_16BIT: - horizontalDifference16((uint16 *)bp, llen, - sp->stride, up, sp->From14); - bp += llen * sizeof(uint16); + horizontalDifference16((uint16_t *)bp, llen, + sp->stride, up, sp->From14); + bp += llen * sizeof(uint16_t); break; case PIXARLOGDATAFMT_8BIT: horizontalDifference8((unsigned char *)bp, llen, @@ -1173,7 +1173,7 @@ PixarLogEncode(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) break; default: TIFFErrorExt(tif->tif_clientdata, module, - "%d bit input not supported in PixarLog", + "%"PRIu16" bit input not supported in PixarLog", td->td_bitspersample); return 0; } @@ -1184,8 +1184,8 @@ PixarLogEncode(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) we need to simplify this code to reflect a ZLib that is likely updated to deal with 8byte memory sizes, though this code will respond appropriately even before we simplify it */ - sp->stream.avail_in = (uInt) (n * sizeof(uint16)); - if ((sp->stream.avail_in / sizeof(uint16)) != (uInt) n) + sp->stream.avail_in = (uInt) (n * sizeof(uint16_t)); + if ((sp->stream.avail_in / sizeof(uint16_t)) != (uInt) n) { TIFFErrorExt(tif->tif_clientdata, module, "ZLib cannot deal with buffers this size"); @@ -1309,7 +1309,7 @@ PixarLogCleanup(TIFF* tif) } static int -PixarLogVSetField(TIFF* tif, uint32 tag, va_list ap) +PixarLogVSetField(TIFF* tif, uint32_t tag, va_list ap) { static const char module[] = "PixarLogVSetField"; PixarLogState *sp = (PixarLogState *)tif->tif_data; @@ -1371,7 +1371,7 @@ PixarLogVSetField(TIFF* tif, uint32 tag, va_list ap) } static int -PixarLogVGetField(TIFF* tif, uint32 tag, va_list ap) +PixarLogVGetField(TIFF* tif, uint32_t tag, va_list ap) { PixarLogState *sp = (PixarLogState *)tif->tif_data; @@ -1416,7 +1416,7 @@ TIFFInitPixarLog(TIFF* tif, int scheme) /* * Allocate state block so tag methods have storage to record values. */ - tif->tif_data = (uint8*) _TIFFmalloc(sizeof (PixarLogState)); + tif->tif_data = (uint8_t*) _TIFFmalloc(sizeof (PixarLogState)); if (tif->tif_data == NULL) goto bad; sp = (PixarLogState*) tif->tif_data; diff --git a/tiff/libtiff/tif_predict.c b/tiff/libtiff/tif_predict.c index c0233974..4aa4af69 100644 --- a/tiff/libtiff/tif_predict.c +++ b/tiff/libtiff/tif_predict.c @@ -32,22 +32,22 @@ #define PredictorState(tif) ((TIFFPredictorState*) (tif)->tif_data) -static int horAcc8(TIFF* tif, uint8* cp0, tmsize_t cc); -static int horAcc16(TIFF* tif, uint8* cp0, tmsize_t cc); -static int horAcc32(TIFF* tif, uint8* cp0, tmsize_t cc); -static int swabHorAcc16(TIFF* tif, uint8* cp0, tmsize_t cc); -static int swabHorAcc32(TIFF* tif, uint8* cp0, tmsize_t cc); -static int horDiff8(TIFF* tif, uint8* cp0, tmsize_t cc); -static int horDiff16(TIFF* tif, uint8* cp0, tmsize_t cc); -static int horDiff32(TIFF* tif, uint8* cp0, tmsize_t cc); -static int swabHorDiff16(TIFF* tif, uint8* cp0, tmsize_t cc); -static int swabHorDiff32(TIFF* tif, uint8* cp0, tmsize_t cc); -static int fpAcc(TIFF* tif, uint8* cp0, tmsize_t cc); -static int fpDiff(TIFF* tif, uint8* cp0, tmsize_t cc); -static int PredictorDecodeRow(TIFF* tif, uint8* op0, tmsize_t occ0, uint16 s); -static int PredictorDecodeTile(TIFF* tif, uint8* op0, tmsize_t occ0, uint16 s); -static int PredictorEncodeRow(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s); -static int PredictorEncodeTile(TIFF* tif, uint8* bp0, tmsize_t cc0, uint16 s); +static int horAcc8(TIFF* tif, uint8_t* cp0, tmsize_t cc); +static int horAcc16(TIFF* tif, uint8_t* cp0, tmsize_t cc); +static int horAcc32(TIFF* tif, uint8_t* cp0, tmsize_t cc); +static int swabHorAcc16(TIFF* tif, uint8_t* cp0, tmsize_t cc); +static int swabHorAcc32(TIFF* tif, uint8_t* cp0, tmsize_t cc); +static int horDiff8(TIFF* tif, uint8_t* cp0, tmsize_t cc); +static int horDiff16(TIFF* tif, uint8_t* cp0, tmsize_t cc); +static int horDiff32(TIFF* tif, uint8_t* cp0, tmsize_t cc); +static int swabHorDiff16(TIFF* tif, uint8_t* cp0, tmsize_t cc); +static int swabHorDiff32(TIFF* tif, uint8_t* cp0, tmsize_t cc); +static int fpAcc(TIFF* tif, uint8_t* cp0, tmsize_t cc); +static int fpDiff(TIFF* tif, uint8_t* cp0, tmsize_t cc); +static int PredictorDecodeRow(TIFF* tif, uint8_t* op0, tmsize_t occ0, uint16_t s); +static int PredictorDecodeTile(TIFF* tif, uint8_t* op0, tmsize_t occ0, uint16_t s); +static int PredictorEncodeRow(TIFF* tif, uint8_t* bp, tmsize_t cc, uint16_t s); +static int PredictorEncodeTile(TIFF* tif, uint8_t* bp0, tmsize_t cc0, uint16_t s); static int PredictorSetup(TIFF* tif) @@ -66,7 +66,7 @@ PredictorSetup(TIFF* tif) && td->td_bitspersample != 16 && td->td_bitspersample != 32) { TIFFErrorExt(tif->tif_clientdata, module, - "Horizontal differencing \"Predictor\" not supported with %d-bit samples", + "Horizontal differencing \"Predictor\" not supported with %"PRIu16"-bit samples", td->td_bitspersample); return 0; } @@ -74,7 +74,7 @@ PredictorSetup(TIFF* tif) case PREDICTOR_FLOATINGPOINT: if (td->td_sampleformat != SAMPLEFORMAT_IEEEFP) { TIFFErrorExt(tif->tif_clientdata, module, - "Floating point \"Predictor\" not supported with %d data format", + "Floating point \"Predictor\" not supported with %"PRIu16" data format", td->td_sampleformat); return 0; } @@ -83,7 +83,7 @@ PredictorSetup(TIFF* tif) && td->td_bitspersample != 32 && td->td_bitspersample != 64) { /* Should 64 be allowed? */ TIFFErrorExt(tif->tif_clientdata, module, - "Floating point \"Predictor\" not supported with %d-bit samples", + "Floating point \"Predictor\" not supported with %"PRIu16"-bit samples", td->td_bitspersample); return 0; } @@ -277,7 +277,7 @@ PredictorSetupEncode(TIFF* tif) TIFF_NOSANITIZE_UNSIGNED_INT_OVERFLOW static int -horAcc8(TIFF* tif, uint8* cp0, tmsize_t cc) +horAcc8(TIFF* tif, uint8_t* cp0, tmsize_t cc) { tmsize_t stride = PredictorState(tif)->stride; @@ -334,9 +334,9 @@ horAcc8(TIFF* tif, uint8* cp0, tmsize_t cc) } static int -swabHorAcc16(TIFF* tif, uint8* cp0, tmsize_t cc) +swabHorAcc16(TIFF* tif, uint8_t* cp0, tmsize_t cc) { - uint16* wp = (uint16*) cp0; + uint16_t* wp = (uint16_t*) cp0; tmsize_t wc = cc / 2; TIFFSwabArrayOfShort(wp, wc); @@ -345,10 +345,10 @@ swabHorAcc16(TIFF* tif, uint8* cp0, tmsize_t cc) TIFF_NOSANITIZE_UNSIGNED_INT_OVERFLOW static int -horAcc16(TIFF* tif, uint8* cp0, tmsize_t cc) +horAcc16(TIFF* tif, uint8_t* cp0, tmsize_t cc) { tmsize_t stride = PredictorState(tif)->stride; - uint16* wp = (uint16*) cp0; + uint16_t* wp = (uint16_t*) cp0; tmsize_t wc = cc / 2; if((cc%(2*stride))!=0) @@ -361,7 +361,7 @@ horAcc16(TIFF* tif, uint8* cp0, tmsize_t cc) if (wc > stride) { wc -= stride; do { - REPEAT4(stride, wp[stride] = (uint16)(((unsigned int)wp[stride] + (unsigned int)wp[0]) & 0xffff); wp++) + REPEAT4(stride, wp[stride] = (uint16_t)(((unsigned int)wp[stride] + (unsigned int)wp[0]) & 0xffff); wp++) wc -= stride; } while (wc > 0); } @@ -369,9 +369,9 @@ horAcc16(TIFF* tif, uint8* cp0, tmsize_t cc) } static int -swabHorAcc32(TIFF* tif, uint8* cp0, tmsize_t cc) +swabHorAcc32(TIFF* tif, uint8_t* cp0, tmsize_t cc) { - uint32* wp = (uint32*) cp0; + uint32_t* wp = (uint32_t*) cp0; tmsize_t wc = cc / 4; TIFFSwabArrayOfLong(wp, wc); @@ -380,10 +380,10 @@ swabHorAcc32(TIFF* tif, uint8* cp0, tmsize_t cc) TIFF_NOSANITIZE_UNSIGNED_INT_OVERFLOW static int -horAcc32(TIFF* tif, uint8* cp0, tmsize_t cc) +horAcc32(TIFF* tif, uint8_t* cp0, tmsize_t cc) { tmsize_t stride = PredictorState(tif)->stride; - uint32* wp = (uint32*) cp0; + uint32_t* wp = (uint32_t*) cp0; tmsize_t wc = cc / 4; if((cc%(4*stride))!=0) @@ -407,14 +407,14 @@ horAcc32(TIFF* tif, uint8* cp0, tmsize_t cc) * Floating point predictor accumulation routine. */ static int -fpAcc(TIFF* tif, uint8* cp0, tmsize_t cc) +fpAcc(TIFF* tif, uint8_t* cp0, tmsize_t cc) { tmsize_t stride = PredictorState(tif)->stride; - uint32 bps = tif->tif_dir.td_bitspersample / 8; + uint32_t bps = tif->tif_dir.td_bitspersample / 8; tmsize_t wc = cc / bps; tmsize_t count = cc; - uint8 *cp = (uint8 *) cp0; - uint8 *tmp; + uint8_t *cp = (uint8_t *) cp0; + uint8_t *tmp; if(cc%(bps*stride)!=0) { @@ -423,7 +423,7 @@ fpAcc(TIFF* tif, uint8* cp0, tmsize_t cc) return 0; } - tmp = (uint8 *)_TIFFmalloc(cc); + tmp = (uint8_t *)_TIFFmalloc(cc); if (!tmp) return 0; @@ -434,9 +434,9 @@ fpAcc(TIFF* tif, uint8* cp0, tmsize_t cc) } _TIFFmemcpy(tmp, cp0, cc); - cp = (uint8 *) cp0; + cp = (uint8_t *) cp0; for (count = 0; count < wc; count++) { - uint32 byte; + uint32_t byte; for (byte = 0; byte < bps; byte++) { #if WORDS_BIGENDIAN cp[bps * count + byte] = tmp[byte * wc + count]; @@ -454,7 +454,7 @@ fpAcc(TIFF* tif, uint8* cp0, tmsize_t cc) * Decode a scanline and apply the predictor routine. */ static int -PredictorDecodeRow(TIFF* tif, uint8* op0, tmsize_t occ0, uint16 s) +PredictorDecodeRow(TIFF* tif, uint8_t* op0, tmsize_t occ0, uint16_t s) { TIFFPredictorState *sp = PredictorState(tif); @@ -476,7 +476,7 @@ PredictorDecodeRow(TIFF* tif, uint8* op0, tmsize_t occ0, uint16 s) * strip/tile dimensions. */ static int -PredictorDecodeTile(TIFF* tif, uint8* op0, tmsize_t occ0, uint16 s) +PredictorDecodeTile(TIFF* tif, uint8_t* op0, tmsize_t occ0, uint16_t s) { TIFFPredictorState *sp = PredictorState(tif); @@ -506,7 +506,7 @@ PredictorDecodeTile(TIFF* tif, uint8* op0, tmsize_t occ0, uint16 s) TIFF_NOSANITIZE_UNSIGNED_INT_OVERFLOW static int -horDiff8(TIFF* tif, uint8* cp0, tmsize_t cc) +horDiff8(TIFF* tif, uint8_t* cp0, tmsize_t cc) { TIFFPredictorState* sp = PredictorState(tif); tmsize_t stride = sp->stride; @@ -560,11 +560,11 @@ horDiff8(TIFF* tif, uint8* cp0, tmsize_t cc) TIFF_NOSANITIZE_UNSIGNED_INT_OVERFLOW static int -horDiff16(TIFF* tif, uint8* cp0, tmsize_t cc) +horDiff16(TIFF* tif, uint8_t* cp0, tmsize_t cc) { TIFFPredictorState* sp = PredictorState(tif); tmsize_t stride = sp->stride; - uint16 *wp = (uint16*) cp0; + uint16_t *wp = (uint16_t*) cp0; tmsize_t wc = cc/2; if((cc%(2*stride))!=0) @@ -578,7 +578,7 @@ horDiff16(TIFF* tif, uint8* cp0, tmsize_t cc) wc -= stride; wp += wc - 1; do { - REPEAT4(stride, wp[stride] = (uint16)(((unsigned int)wp[stride] - (unsigned int)wp[0]) & 0xffff); wp--) + REPEAT4(stride, wp[stride] = (uint16_t)(((unsigned int)wp[stride] - (unsigned int)wp[0]) & 0xffff); wp--) wc -= stride; } while (wc > 0); } @@ -586,9 +586,9 @@ horDiff16(TIFF* tif, uint8* cp0, tmsize_t cc) } static int -swabHorDiff16(TIFF* tif, uint8* cp0, tmsize_t cc) +swabHorDiff16(TIFF* tif, uint8_t* cp0, tmsize_t cc) { - uint16* wp = (uint16*) cp0; + uint16_t* wp = (uint16_t*) cp0; tmsize_t wc = cc / 2; if( !horDiff16(tif, cp0, cc) ) @@ -600,11 +600,11 @@ swabHorDiff16(TIFF* tif, uint8* cp0, tmsize_t cc) TIFF_NOSANITIZE_UNSIGNED_INT_OVERFLOW static int -horDiff32(TIFF* tif, uint8* cp0, tmsize_t cc) +horDiff32(TIFF* tif, uint8_t* cp0, tmsize_t cc) { TIFFPredictorState* sp = PredictorState(tif); tmsize_t stride = sp->stride; - uint32 *wp = (uint32*) cp0; + uint32_t *wp = (uint32_t*) cp0; tmsize_t wc = cc/4; if((cc%(4*stride))!=0) @@ -626,9 +626,9 @@ horDiff32(TIFF* tif, uint8* cp0, tmsize_t cc) } static int -swabHorDiff32(TIFF* tif, uint8* cp0, tmsize_t cc) +swabHorDiff32(TIFF* tif, uint8_t* cp0, tmsize_t cc) { - uint32* wp = (uint32*) cp0; + uint32_t* wp = (uint32_t*) cp0; tmsize_t wc = cc / 4; if( !horDiff32(tif, cp0, cc) ) @@ -643,14 +643,14 @@ swabHorDiff32(TIFF* tif, uint8* cp0, tmsize_t cc) */ TIFF_NOSANITIZE_UNSIGNED_INT_OVERFLOW static int -fpDiff(TIFF* tif, uint8* cp0, tmsize_t cc) +fpDiff(TIFF* tif, uint8_t* cp0, tmsize_t cc) { tmsize_t stride = PredictorState(tif)->stride; - uint32 bps = tif->tif_dir.td_bitspersample / 8; + uint32_t bps = tif->tif_dir.td_bitspersample / 8; tmsize_t wc = cc / bps; tmsize_t count; - uint8 *cp = (uint8 *) cp0; - uint8 *tmp; + uint8_t *cp = (uint8_t *) cp0; + uint8_t *tmp; if((cc%(bps*stride))!=0) { @@ -659,13 +659,13 @@ fpDiff(TIFF* tif, uint8* cp0, tmsize_t cc) return 0; } - tmp = (uint8 *)_TIFFmalloc(cc); + tmp = (uint8_t *)_TIFFmalloc(cc); if (!tmp) return 0; _TIFFmemcpy(tmp, cp0, cc); for (count = 0; count < wc; count++) { - uint32 byte; + uint32_t byte; for (byte = 0; byte < bps; byte++) { #if WORDS_BIGENDIAN cp[byte * wc + count] = tmp[bps * count + byte]; @@ -677,7 +677,7 @@ fpDiff(TIFF* tif, uint8* cp0, tmsize_t cc) } _TIFFfree(tmp); - cp = (uint8 *) cp0; + cp = (uint8_t *) cp0; cp += cc - stride - 1; for (count = cc; count > stride; count -= stride) REPEAT4(stride, cp[stride] = (unsigned char)((cp[stride] - cp[0])&0xff); cp--) @@ -685,7 +685,7 @@ fpDiff(TIFF* tif, uint8* cp0, tmsize_t cc) } static int -PredictorEncodeRow(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) +PredictorEncodeRow(TIFF* tif, uint8_t* bp, tmsize_t cc, uint16_t s) { TIFFPredictorState *sp = PredictorState(tif); @@ -700,11 +700,11 @@ PredictorEncodeRow(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) } static int -PredictorEncodeTile(TIFF* tif, uint8* bp0, tmsize_t cc0, uint16 s) +PredictorEncodeTile(TIFF* tif, uint8_t* bp0, tmsize_t cc0, uint16_t s) { static const char module[] = "PredictorEncodeTile"; TIFFPredictorState *sp = PredictorState(tif); - uint8 *working_copy; + uint8_t *working_copy; tmsize_t cc = cc0, rowsize; unsigned char* bp; int result_code; @@ -717,12 +717,12 @@ PredictorEncodeTile(TIFF* tif, uint8* bp0, tmsize_t cc0, uint16 s) * 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); + working_copy = (uint8_t*) _TIFFmalloc(cc0); if( working_copy == NULL ) { TIFFErrorExt(tif->tif_clientdata, module, - "Out of memory allocating " TIFF_SSIZE_FORMAT " byte temp buffer.", - cc0 ); + "Out of memory allocating %" PRId64 " byte temp buffer.", + (int64_t) cc0 ); return 0; } memcpy( working_copy, bp0, cc0 ); @@ -756,7 +756,7 @@ static const TIFFField predictFields[] = { }; static int -PredictorVSetField(TIFF* tif, uint32 tag, va_list ap) +PredictorVSetField(TIFF* tif, uint32_t tag, va_list ap) { TIFFPredictorState *sp = PredictorState(tif); @@ -765,7 +765,7 @@ PredictorVSetField(TIFF* tif, uint32 tag, va_list ap) switch (tag) { case TIFFTAG_PREDICTOR: - sp->predictor = (uint16) va_arg(ap, uint16_vap); + sp->predictor = (uint16_t) va_arg(ap, uint16_vap); TIFFSetFieldBit(tif, FIELD_PREDICTOR); break; default: @@ -776,7 +776,7 @@ PredictorVSetField(TIFF* tif, uint32 tag, va_list ap) } static int -PredictorVGetField(TIFF* tif, uint32 tag, va_list ap) +PredictorVGetField(TIFF* tif, uint32_t tag, va_list ap) { TIFFPredictorState *sp = PredictorState(tif); @@ -785,7 +785,7 @@ PredictorVGetField(TIFF* tif, uint32 tag, va_list ap) switch (tag) { case TIFFTAG_PREDICTOR: - *va_arg(ap, uint16*) = (uint16)sp->predictor; + *va_arg(ap, uint16_t*) = (uint16_t)sp->predictor; break; default: return (*sp->vgetparent)(tif, tag, ap); diff --git a/tiff/libtiff/tif_predict.h b/tiff/libtiff/tif_predict.h index a326b9b8..597faa16 100644 --- a/tiff/libtiff/tif_predict.h +++ b/tiff/libtiff/tif_predict.h @@ -32,7 +32,7 @@ * ``Library-private'' Support for the Predictor Tag */ -typedef int (*TIFFEncodeDecodeMethod)(TIFF* tif, uint8* buf, tmsize_t size); +typedef int (*TIFFEncodeDecodeMethod)(TIFF* tif, uint8_t* buf, tmsize_t size); /* * Codecs that want to support the Predictor tag must place diff --git a/tiff/libtiff/tif_print.c b/tiff/libtiff/tif_print.c index a0737941..347dbdaf 100644 --- a/tiff/libtiff/tif_print.c +++ b/tiff/libtiff/tif_print.c @@ -65,62 +65,43 @@ static const char * const orientNames[] = { static void _TIFFPrintField(FILE* fd, const TIFFField *fip, - uint32 value_count, void *raw_data) + uint32_t value_count, void *raw_data) { - uint32 j; + uint32_t j; fprintf(fd, " %s: ", fip->field_name); for(j = 0; j < value_count; j++) { if(fip->field_type == TIFF_BYTE) - fprintf(fd, "%u", ((uint8 *) raw_data)[j]); + fprintf(fd, "%"PRIu8, ((uint8_t *) raw_data)[j]); else if(fip->field_type == TIFF_UNDEFINED) - fprintf(fd, "0x%x", - (unsigned int) ((unsigned char *) raw_data)[j]); + fprintf(fd, "0x%"PRIx8, ((uint8_t *) raw_data)[j]); else if(fip->field_type == TIFF_SBYTE) - fprintf(fd, "%d", ((int8 *) raw_data)[j]); + fprintf(fd, "%"PRId8, ((int8_t *) raw_data)[j]); else if(fip->field_type == TIFF_SHORT) - fprintf(fd, "%u", ((uint16 *) raw_data)[j]); + fprintf(fd, "%"PRIu16, ((uint16_t *) raw_data)[j]); else if(fip->field_type == TIFF_SSHORT) - fprintf(fd, "%d", ((int16 *) raw_data)[j]); + fprintf(fd, "%"PRId16, ((int16_t *) raw_data)[j]); else if(fip->field_type == TIFF_LONG) - fprintf(fd, "%lu", - (unsigned long)((uint32 *) raw_data)[j]); + fprintf(fd, "%"PRIu32, ((uint32_t *) raw_data)[j]); else if(fip->field_type == TIFF_SLONG) - fprintf(fd, "%ld", (long)((int32 *) raw_data)[j]); + fprintf(fd, "%"PRId32, ((int32_t *) raw_data)[j]); else if(fip->field_type == TIFF_IFD) - fprintf(fd, "0x%lx", - (unsigned long)((uint32 *) raw_data)[j]); + fprintf(fd, "0x%"PRIx32, ((uint32_t *) raw_data)[j]); else if(fip->field_type == TIFF_RATIONAL || fip->field_type == TIFF_SRATIONAL || fip->field_type == TIFF_FLOAT) fprintf(fd, "%f", ((float *) raw_data)[j]); else if(fip->field_type == TIFF_LONG8) -#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__)) - fprintf(fd, "%I64u", - (unsigned __int64)((uint64 *) raw_data)[j]); -#else - fprintf(fd, "%llu", - (unsigned long long)((uint64 *) raw_data)[j]); -#endif + fprintf(fd, "%"PRIu64, ((uint64_t *) raw_data)[j]); else if(fip->field_type == TIFF_SLONG8) -#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__)) - fprintf(fd, "%I64d", (__int64)((int64 *) raw_data)[j]); -#else - fprintf(fd, "%lld", (long long)((int64 *) raw_data)[j]); -#endif + fprintf(fd, "%"PRId64, ((int64_t *) raw_data)[j]); else if(fip->field_type == TIFF_IFD8) -#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__)) - fprintf(fd, "0x%I64x", - (unsigned __int64)((uint64 *) raw_data)[j]); -#else - fprintf(fd, "0x%llx", - (unsigned long long)((uint64 *) raw_data)[j]); -#endif + fprintf(fd, "0x%"PRIx64, ((uint64_t *) raw_data)[j]); else if(fip->field_type == TIFF_FLOAT) fprintf(fd, "%f", ((float *)raw_data)[j]); else if(fip->field_type == TIFF_DOUBLE) - fprintf(fd, "%f", ((double *) raw_data)[j]); + fprintf(fd, "%lf", ((double *) raw_data)[j]); else if(fip->field_type == TIFF_ASCII) { fprintf(fd, "%s", (char *) raw_data); break; @@ -138,8 +119,8 @@ _TIFFPrintField(FILE* fd, const TIFFField *fip, } static int -_TIFFPrettyPrintField(TIFF* tif, const TIFFField *fip, FILE* fd, uint32 tag, - uint32 value_count, void *raw_data) +_TIFFPrettyPrintField(TIFF* tif, const TIFFField *fip, FILE* fd, uint32_t tag, + uint32_t value_count, void *raw_data) { (void) tif; @@ -153,14 +134,14 @@ _TIFFPrettyPrintField(TIFF* tif, const TIFFField *fip, FILE* fd, uint32 tag, case TIFFTAG_INKSET: if (value_count == 2 && fip->field_type == TIFF_SHORT) { fprintf(fd, " Ink Set: "); - switch (*((uint16*)raw_data)) { + switch (*((uint16_t*)raw_data)) { case INKSET_CMYK: fprintf(fd, "CMYK\n"); break; default: - fprintf(fd, "%u (0x%x)\n", - *((uint16*)raw_data), - *((uint16*)raw_data)); + fprintf(fd, "%"PRIu16" (0x%"PRIx16")\n", + *((uint16_t*)raw_data), + *((uint16_t*)raw_data)); break; } return 1; @@ -169,8 +150,8 @@ _TIFFPrettyPrintField(TIFF* tif, const TIFFField *fip, FILE* fd, uint32 tag, case TIFFTAG_DOTRANGE: if (value_count == 2 && fip->field_type == TIFF_SHORT) { - fprintf(fd, " Dot Range: %u-%u\n", - ((uint16*)raw_data)[0], ((uint16*)raw_data)[1]); + fprintf(fd, " Dot Range: %"PRIu16"-%"PRIu16"\n", + ((uint16_t*)raw_data)[0], ((uint16_t*)raw_data)[1]); return 1; } return 0; @@ -185,7 +166,7 @@ _TIFFPrettyPrintField(TIFF* tif, const TIFFField *fip, FILE* fd, uint32 tag, case TIFFTAG_XMLPACKET: { - uint32 i; + uint32_t i; fprintf(fd, " XMLPacket (XMP Metadata):\n" ); for(i = 0; i < value_count; i++) @@ -199,18 +180,18 @@ _TIFFPrettyPrintField(TIFF* tif, const TIFFField *fip, FILE* fd, uint32 tag, * defined as array of LONG values. */ fprintf(fd, - " RichTIFFIPTC Data: <present>, %lu bytes\n", - (unsigned long) value_count * 4); + " RichTIFFIPTC Data: <present>, %"PRIu32" bytes\n", + value_count * 4u); return 1; case TIFFTAG_PHOTOSHOP: - fprintf(fd, " Photoshop Data: <present>, %lu bytes\n", - (unsigned long) value_count); + fprintf(fd, " Photoshop Data: <present>, %"PRIu32" bytes\n", + value_count); return 1; case TIFFTAG_ICCPROFILE: - fprintf(fd, " ICC Profile: <present>, %lu bytes\n", - (unsigned long) value_count); + fprintf(fd, " ICC Profile: <present>, %"PRIu32" bytes\n", + value_count); return 1; case TIFFTAG_STONITS: @@ -237,15 +218,9 @@ TIFFPrintDirectory(TIFF* tif, FILE* fd, long flags) char *sep; long l, n; -#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__)) - fprintf(fd, "TIFF Directory at offset 0x%I64x (%I64u)\n", - (unsigned __int64) tif->tif_diroff, - (unsigned __int64) tif->tif_diroff); -#else - fprintf(fd, "TIFF Directory at offset 0x%llx (%llu)\n", - (unsigned long long) tif->tif_diroff, - (unsigned long long) tif->tif_diroff); -#endif + fprintf(fd, "TIFF Directory at offset 0x%"PRIu64" (%"PRIx64")\n", + tif->tif_diroff, + tif->tif_diroff); if (TIFFFieldSet(tif,FIELD_SUBFILETYPE)) { fprintf(fd, " Subfile Type:"); sep = " "; @@ -259,23 +234,23 @@ TIFFPrintDirectory(TIFF* tif, FILE* fd, long flags) } if (td->td_subfiletype & FILETYPE_MASK) fprintf(fd, "%stransparency mask", sep); - fprintf(fd, " (%lu = 0x%lx)\n", - (unsigned long) td->td_subfiletype, (long) td->td_subfiletype); + fprintf(fd, " (%"PRIu32" = 0x%"PRIx32")\n", + td->td_subfiletype, td->td_subfiletype); } if (TIFFFieldSet(tif,FIELD_IMAGEDIMENSIONS)) { - fprintf(fd, " Image Width: %lu Image Length: %lu", - (unsigned long) td->td_imagewidth, (unsigned long) td->td_imagelength); + fprintf(fd, " Image Width: %"PRIu32" Image Length: %"PRIu32, + td->td_imagewidth, td->td_imagelength); if (TIFFFieldSet(tif,FIELD_IMAGEDEPTH)) - fprintf(fd, " Image Depth: %lu", - (unsigned long) td->td_imagedepth); + fprintf(fd, " Image Depth: %"PRIu32, + td->td_imagedepth); fprintf(fd, "\n"); } if (TIFFFieldSet(tif,FIELD_TILEDIMENSIONS)) { - fprintf(fd, " Tile Width: %lu Tile Length: %lu", - (unsigned long) td->td_tilewidth, (unsigned long) td->td_tilelength); + fprintf(fd, " Tile Width: %"PRIu32" Tile Length: %"PRIu32, + td->td_tilewidth, td->td_tilelength); if (TIFFFieldSet(tif,FIELD_TILEDEPTH)) - fprintf(fd, " Tile Depth: %lu", - (unsigned long) td->td_tiledepth); + fprintf(fd, " Tile Depth: %"PRIu32, + td->td_tiledepth); fprintf(fd, "\n"); } if (TIFFFieldSet(tif,FIELD_RESOLUTION)) { @@ -293,7 +268,7 @@ TIFFPrintDirectory(TIFF* tif, FILE* fd, long flags) fprintf(fd, " pixels/cm"); break; default: - fprintf(fd, " (unit %u = 0x%x)", + fprintf(fd, " (unit %"PRIu16" = 0x%"PRIx16")", td->td_resolutionunit, td->td_resolutionunit); break; @@ -305,7 +280,7 @@ TIFFPrintDirectory(TIFF* tif, FILE* fd, long flags) fprintf(fd, " Position: %g, %g\n", td->td_xposition, td->td_yposition); if (TIFFFieldSet(tif,FIELD_BITSPERSAMPLE)) - fprintf(fd, " Bits/Sample: %u\n", td->td_bitspersample); + fprintf(fd, " Bits/Sample: %"PRIu16"\n", td->td_bitspersample); if (TIFFFieldSet(tif,FIELD_SAMPLEFORMAT)) { fprintf(fd, " Sample Format: "); switch (td->td_sampleformat) { @@ -328,7 +303,7 @@ TIFFPrintDirectory(TIFF* tif, FILE* fd, long flags) fprintf(fd, "complex IEEE floating point\n"); break; default: - fprintf(fd, "%u (0x%x)\n", + fprintf(fd, "%"PRIu16" (0x%"PRIx16")\n", td->td_sampleformat, td->td_sampleformat); break; } @@ -339,7 +314,7 @@ TIFFPrintDirectory(TIFF* tif, FILE* fd, long flags) if (c) fprintf(fd, "%s\n", c->name); else - fprintf(fd, "%u (0x%x)\n", + fprintf(fd, "%"PRIu16" (0x%"PRIx16")\n", td->td_compression, td->td_compression); } if (TIFFFieldSet(tif,FIELD_PHOTOMETRIC)) { @@ -355,15 +330,15 @@ TIFFPrintDirectory(TIFF* tif, FILE* fd, long flags) fprintf(fd, "CIE Log2(L) (u',v')\n"); break; default: - fprintf(fd, "%u (0x%x)\n", + fprintf(fd, "%"PRIu16" (0x%"PRIx16")\n", td->td_photometric, td->td_photometric); break; } } } if (TIFFFieldSet(tif,FIELD_EXTRASAMPLES) && td->td_extrasamples) { - uint16 i; - fprintf(fd, " Extra Samples: %u<", td->td_extrasamples); + uint16_t i; + fprintf(fd, " Extra Samples: %"PRIu16"<", td->td_extrasamples); sep = ""; for (i = 0; i < td->td_extrasamples; i++) { switch (td->td_sampleinfo[i]) { @@ -377,7 +352,7 @@ TIFFPrintDirectory(TIFF* tif, FILE* fd, long flags) fprintf(fd, "%sunassoc-alpha", sep); break; default: - fprintf(fd, "%s%u (0x%x)", sep, + fprintf(fd, "%s%"PRIu16" (0x%"PRIx16")", sep, td->td_sampleinfo[i], td->td_sampleinfo[i]); break; } @@ -387,7 +362,7 @@ TIFFPrintDirectory(TIFF* tif, FILE* fd, long flags) } if (TIFFFieldSet(tif,FIELD_INKNAMES)) { char* cp; - uint16 i; + uint16_t i; fprintf(fd, " Ink Names: "); i = td->td_samplesperpixel; sep = ""; @@ -415,7 +390,7 @@ TIFFPrintDirectory(TIFF* tif, FILE* fd, long flags) fprintf(fd, "error diffused\n"); break; default: - fprintf(fd, "%u (0x%x)\n", + fprintf(fd, "%"PRIu16" (0x%"PRIx16")\n", td->td_threshholding, td->td_threshholding); break; } @@ -430,14 +405,14 @@ TIFFPrintDirectory(TIFF* tif, FILE* fd, long flags) fprintf(fd, "lsb-to-msb\n"); break; default: - fprintf(fd, "%u (0x%x)\n", + fprintf(fd, "%"PRIu16" (0x%"PRIx16")\n", td->td_fillorder, td->td_fillorder); break; } } if (TIFFFieldSet(tif,FIELD_YCBCRSUBSAMPLING)) { - fprintf(fd, " YCbCr Subsampling: %u, %u\n", + fprintf(fd, " YCbCr Subsampling: %"PRIu16", %"PRIu16"\n", td->td_ycbcrsubsampling[0], td->td_ycbcrsubsampling[1] ); } if (TIFFFieldSet(tif,FIELD_YCBCRPOSITIONING)) { @@ -450,35 +425,35 @@ TIFFPrintDirectory(TIFF* tif, FILE* fd, long flags) fprintf(fd, "cosited\n"); break; default: - fprintf(fd, "%u (0x%x)\n", + fprintf(fd, "%"PRIu16" (0x%"PRIx16")\n", td->td_ycbcrpositioning, td->td_ycbcrpositioning); break; } } if (TIFFFieldSet(tif,FIELD_HALFTONEHINTS)) - fprintf(fd, " Halftone Hints: light %u dark %u\n", + fprintf(fd, " Halftone Hints: light %"PRIu16" dark %"PRIu16"\n", td->td_halftonehints[0], td->td_halftonehints[1]); if (TIFFFieldSet(tif,FIELD_ORIENTATION)) { fprintf(fd, " Orientation: "); if (td->td_orientation < NORIENTNAMES) fprintf(fd, "%s\n", orientNames[td->td_orientation]); else - fprintf(fd, "%u (0x%x)\n", + fprintf(fd, "%"PRIu16" (0x%"PRIx16")\n", td->td_orientation, td->td_orientation); } if (TIFFFieldSet(tif,FIELD_SAMPLESPERPIXEL)) - fprintf(fd, " Samples/Pixel: %u\n", td->td_samplesperpixel); + fprintf(fd, " Samples/Pixel: %"PRIx16"\n", td->td_samplesperpixel); if (TIFFFieldSet(tif,FIELD_ROWSPERSTRIP)) { fprintf(fd, " Rows/Strip: "); - if (td->td_rowsperstrip == (uint32) -1) + if (td->td_rowsperstrip == (uint32_t) -1) fprintf(fd, "(infinite)\n"); else - fprintf(fd, "%lu\n", (unsigned long) td->td_rowsperstrip); + fprintf(fd, "%"PRIu32"\n", td->td_rowsperstrip); } if (TIFFFieldSet(tif,FIELD_MINSAMPLEVALUE)) - fprintf(fd, " Min Sample Value: %u\n", td->td_minsamplevalue); + fprintf(fd, " Min Sample Value: %"PRIu16"\n", td->td_minsamplevalue); if (TIFFFieldSet(tif,FIELD_MAXSAMPLEVALUE)) - fprintf(fd, " Max Sample Value: %u\n", td->td_maxsamplevalue); + fprintf(fd, " Max Sample Value: %"PRIu16"\n", td->td_maxsamplevalue); if (TIFFFieldSet(tif,FIELD_SMINSAMPLEVALUE)) { int i; int count = (tif->tif_flags & TIFF_PERSAMPLE) ? td->td_samplesperpixel : 1; @@ -505,13 +480,13 @@ TIFFPrintDirectory(TIFF* tif, FILE* fd, long flags) fprintf(fd, "separate image planes\n"); break; default: - fprintf(fd, "%u (0x%x)\n", + fprintf(fd, "%"PRIu16" (0x%"PRIx16")\n", td->td_planarconfig, td->td_planarconfig); break; } } if (TIFFFieldSet(tif,FIELD_PAGENUMBER)) - fprintf(fd, " Page Number: %u-%u\n", + fprintf(fd, " Page Number: %"PRIu16"-%"PRIu16"\n", td->td_pagenumber[0], td->td_pagenumber[1]); if (TIFFFieldSet(tif,FIELD_COLORMAP)) { fprintf(fd, " Color Map: "); @@ -519,7 +494,7 @@ TIFFPrintDirectory(TIFF* tif, FILE* fd, long flags) fprintf(fd, "\n"); n = 1L<<td->td_bitspersample; for (l = 0; l < n; l++) - fprintf(fd, " %5ld: %5u %5u %5u\n", + fprintf(fd, " %5ld: %5"PRIu16" %5"PRIu16" %5"PRIu16"\n", l, td->td_colormap[0][l], td->td_colormap[1][l], @@ -541,11 +516,11 @@ TIFFPrintDirectory(TIFF* tif, FILE* fd, long flags) fprintf(fd, "\n"); n = 1L<<td->td_bitspersample; for (l = 0; l < n; l++) { - uint16 i; - fprintf(fd, " %2ld: %5u", + uint16_t i; + fprintf(fd, " %2ld: %5"PRIu16, l, td->td_transferfunction[0][l]); for (i = 1; i < td->td_samplesperpixel - td->td_extrasamples && i < 3; i++) - fprintf(fd, " %5u", + fprintf(fd, " %5"PRIu16, td->td_transferfunction[i][l]); fputc('\n', fd); } @@ -553,16 +528,11 @@ TIFFPrintDirectory(TIFF* tif, FILE* fd, long flags) fprintf(fd, "(present)\n"); } if (TIFFFieldSet(tif, FIELD_SUBIFD) && (td->td_subifd)) { - uint16 i; + uint16_t i; fprintf(fd, " SubIFD Offsets:"); for (i = 0; i < td->td_nsubifd; i++) -#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__)) - fprintf(fd, " %5I64u", - (unsigned __int64) td->td_subifd[i]); -#else - fprintf(fd, " %5llu", - (unsigned long long) td->td_subifd[i]); -#endif + fprintf(fd, " %5"PRIu64, + td->td_subifd[i]); fputc('\n', fd); } @@ -575,9 +545,9 @@ TIFFPrintDirectory(TIFF* tif, FILE* fd, long flags) count = (short) TIFFGetTagListCount(tif); for(i = 0; i < count; i++) { - uint32 tag = TIFFGetTagListEntry(tif, i); + uint32_t tag = TIFFGetTagListEntry(tif, i); const TIFFField *fip; - uint32 value_count; + uint32_t value_count; int mem_alloc = 0; void *raw_data; @@ -590,7 +560,7 @@ TIFFPrintDirectory(TIFF* tif, FILE* fd, long flags) if(TIFFGetField(tif, tag, &value_count, &raw_data) != 1) continue; } else if (fip->field_readcount == TIFF_VARIABLE ) { - uint16 small_value_count; + uint16_t small_value_count; if(TIFFGetField(tif, tag, &small_value_count, &raw_data) != 1) continue; value_count = small_value_count; @@ -613,7 +583,7 @@ TIFFPrintDirectory(TIFF* tif, FILE* fd, long flags) handled this way ... likely best if we move it into the directory structure with an explicit field in libtiff 4.1 and assign it a FIELD_ value */ - static uint16 dotrange[2]; + static uint16_t dotrange[2]; raw_data = dotrange; TIFFGetField(tif, tag, dotrange+0, dotrange+1); } else if (fip->field_type == TIFF_ASCII @@ -654,23 +624,16 @@ TIFFPrintDirectory(TIFF* tif, FILE* fd, long flags) if ((flags & TIFFPRINT_STRIPS) && TIFFFieldSet(tif,FIELD_STRIPOFFSETS)) { - uint32 s; + uint32_t s; - fprintf(fd, " %lu %s:\n", - (unsigned long) td->td_nstrips, + fprintf(fd, " %"PRIu32" %s:\n", + td->td_nstrips, isTiled(tif) ? "Tiles" : "Strips"); for (s = 0; s < td->td_nstrips; s++) -#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__)) - fprintf(fd, " %3lu: [%8I64u, %8I64u]\n", - (unsigned long) s, - (unsigned __int64) TIFFGetStrileOffset(tif, s), - (unsigned __int64) TIFFGetStrileByteCount(tif, s)); -#else - fprintf(fd, " %3lu: [%8llu, %8llu]\n", - (unsigned long) s, - (unsigned long long) TIFFGetStrileOffset(tif, s), - (unsigned long long) TIFFGetStrileByteCount(tif, s)); -#endif + fprintf(fd, " %3"PRIu32": [%8"PRIu64", %8"PRIu64"]\n", + s, + TIFFGetStrileOffset(tif, s), + TIFFGetStrileByteCount(tif, s)); } } diff --git a/tiff/libtiff/tif_read.c b/tiff/libtiff/tif_read.c index c4c868b1..a4c60b4f 100644 --- a/tiff/libtiff/tif_read.c +++ b/tiff/libtiff/tif_read.c @@ -29,31 +29,31 @@ #include "tiffiop.h" #include <stdio.h> -int TIFFFillStrip(TIFF* tif, uint32 strip); -int TIFFFillTile(TIFF* tif, uint32 tile); -static int TIFFStartStrip(TIFF* tif, uint32 strip); -static int TIFFStartTile(TIFF* tif, uint32 tile); +int TIFFFillStrip(TIFF* tif, uint32_t strip); +int TIFFFillTile(TIFF* tif, uint32_t tile); +static int TIFFStartStrip(TIFF* tif, uint32_t strip); +static int TIFFStartTile(TIFF* tif, uint32_t tile); static int TIFFCheckRead(TIFF*, int); static tmsize_t -TIFFReadRawStrip1(TIFF* tif, uint32 strip, void* buf, tmsize_t size,const char* module); +TIFFReadRawStrip1(TIFF* tif, uint32_t strip, void* buf, tmsize_t size, const char* module); static tmsize_t -TIFFReadRawTile1(TIFF* tif, uint32 tile, void* buf, tmsize_t size, const char* module); +TIFFReadRawTile1(TIFF* tif, uint32_t tile, void* buf, tmsize_t size, const char* module); -#define NOSTRIP ((uint32)(-1)) /* undefined state */ -#define NOTILE ((uint32)(-1)) /* undefined state */ +#define NOSTRIP ((uint32_t)(-1)) /* undefined state */ +#define NOTILE ((uint32_t)(-1)) /* undefined state */ #define INITIAL_THRESHOLD (1024 * 1024) #define THRESHOLD_MULTIPLIER 10 #define MAX_THRESHOLD (THRESHOLD_MULTIPLIER * THRESHOLD_MULTIPLIER * THRESHOLD_MULTIPLIER * INITIAL_THRESHOLD) -#define TIFF_INT64_MAX ((((int64)0x7FFFFFFF) << 32) | 0xFFFFFFFF) +#define TIFF_INT64_MAX ((((int64_t)0x7FFFFFFF) << 32) | 0xFFFFFFFF) /* Read 'size' bytes in tif_rawdata buffer starting at offset 'rawdata_offset' * Returns 1 in case of success, 0 otherwise. */ -static int TIFFReadAndRealloc( TIFF* tif, tmsize_t size, - tmsize_t rawdata_offset, - int is_strip, uint32 strip_or_tile, - const char* module ) +static int TIFFReadAndRealloc(TIFF* tif, tmsize_t size, + tmsize_t rawdata_offset, + int is_strip, uint32_t strip_or_tile, + const char* module ) { #if SIZEOF_SIZE_T == 8 tmsize_t threshold = INITIAL_THRESHOLD; @@ -66,8 +66,8 @@ static int TIFFReadAndRealloc( TIFF* tif, tmsize_t size, /* file size */ if( size > 1000 * 1000 * 1000 ) { - uint64 filesize = TIFFGetFileSize(tif); - if( (uint64)size >= filesize ) + uint64_t filesize = TIFFGetFileSize(tif); + if((uint64_t)size >= filesize ) { TIFFErrorExt(tif->tif_clientdata, module, "Chunk size requested is larger than file size."); @@ -95,22 +95,22 @@ static int TIFFReadAndRealloc( TIFF* tif, tmsize_t size, } #endif if (already_read + to_read + rawdata_offset > tif->tif_rawdatasize) { - uint8* new_rawdata; + uint8_t* new_rawdata; assert((tif->tif_flags & TIFF_MYBUFFER) != 0); tif->tif_rawdatasize = (tmsize_t)TIFFroundup_64( - (uint64)already_read + to_read + rawdata_offset, 1024); + (uint64_t)already_read + to_read + rawdata_offset, 1024); if (tif->tif_rawdatasize==0) { TIFFErrorExt(tif->tif_clientdata, module, "Invalid buffer size"); return 0; } - new_rawdata = (uint8*) _TIFFrealloc( + new_rawdata = (uint8_t*) _TIFFrealloc( tif->tif_rawdata, tif->tif_rawdatasize); if( new_rawdata == 0 ) { TIFFErrorExt(tif->tif_clientdata, module, - "No space for data buffer at scanline %lu", - (unsigned long) tif->tif_row); + "No space for data buffer at scanline %"PRIu32, + tif->tif_row); _TIFFfree(tif->tif_rawdata); tif->tif_rawdata = 0; tif->tif_rawdatasize = 0; @@ -130,49 +130,26 @@ static int TIFFReadAndRealloc( TIFF* tif, tmsize_t size, if (bytes_read != to_read) { memset( tif->tif_rawdata + rawdata_offset + already_read, 0, tif->tif_rawdatasize - rawdata_offset - already_read ); -#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__)) if( is_strip ) { TIFFErrorExt(tif->tif_clientdata, module, - "Read error at scanline %lu; got %I64u bytes, " - "expected %I64u", - (unsigned long) tif->tif_row, - (unsigned __int64) already_read, - (unsigned __int64) size); + "Read error at scanline %"PRIu32"; got %"TIFF_SSIZE_FORMAT" bytes, " + "expected %"TIFF_SSIZE_FORMAT, + tif->tif_row, + already_read, + size); } else { TIFFErrorExt(tif->tif_clientdata, module, - "Read error at row %lu, col %lu, tile %lu; " - "got %I64u bytes, expected %I64u", - (unsigned long) tif->tif_row, - (unsigned long) tif->tif_col, - (unsigned long) strip_or_tile, - (unsigned __int64) already_read, - (unsigned __int64) size); + "Read error at row %"PRIu32", col %"PRIu32", tile %"PRIu32"; " + "got %"TIFF_SSIZE_FORMAT" bytes, expected %"TIFF_SSIZE_FORMAT"", + tif->tif_row, + tif->tif_col, + strip_or_tile, + already_read, + size); } -#else - if( is_strip ) - { - TIFFErrorExt(tif->tif_clientdata, module, - "Read error at scanline %lu; got %llu bytes, " - "expected %llu", - (unsigned long) tif->tif_row, - (unsigned long long) already_read, - (unsigned long long) size); - } - else - { - TIFFErrorExt(tif->tif_clientdata, module, - "Read error at row %lu, col %lu, tile %lu; " - "got %llu bytes, expected %llu", - (unsigned long) tif->tif_row, - (unsigned long) tif->tif_col, - (unsigned long) strip_or_tile, - (unsigned long long) already_read, - (unsigned long long) size); - } -#endif return 0; } } @@ -186,7 +163,7 @@ TIFFFillStripPartial( TIFF *tif, int strip, tmsize_t read_ahead, int restart ) static const char module[] = "TIFFFillStripPartial"; register TIFFDirectory *td = &tif->tif_dir; tmsize_t unused_data; - uint64 read_offset; + uint64_t read_offset; tmsize_t to_read; tmsize_t read_ahead_mod; /* tmsize_t bytecountm; */ @@ -211,8 +188,8 @@ TIFFFillStripPartial( TIFF *tif, int strip, tmsize_t read_ahead, int restart ) tif->tif_curstrip = NOSTRIP; if ((tif->tif_flags & TIFF_MYBUFFER) == 0) { TIFFErrorExt(tif->tif_clientdata, module, - "Data buffer too small to hold part of strip %lu", - (unsigned long) strip); + "Data buffer too small to hold part of strip %d", + strip); return (0); } } @@ -246,8 +223,8 @@ TIFFFillStripPartial( TIFF *tif, int strip, tmsize_t read_ahead, int restart ) if (!SeekOK(tif, read_offset)) { TIFFErrorExt(tif->tif_clientdata, module, - "Seek error at scanline %lu, strip %lu", - (unsigned long) tif->tif_row, (unsigned long) strip); + "Seek error at scanline %"PRIu32", strip %d", + tif->tif_row, strip); return 0; } @@ -258,8 +235,8 @@ TIFFFillStripPartial( TIFF *tif, int strip, tmsize_t read_ahead, int restart ) to_read = read_ahead_mod - unused_data; else to_read = tif->tif_rawdatasize - unused_data; - if( (uint64) to_read > TIFFGetStrileByteCount(tif, strip) - - tif->tif_rawdataoff - tif->tif_rawdataloaded ) + if((uint64_t) to_read > TIFFGetStrileByteCount(tif, strip) + - tif->tif_rawdataoff - tif->tif_rawdataloaded ) { to_read = (tmsize_t) TIFFGetStrileByteCount(tif, strip) - tif->tif_rawdataoff - tif->tif_rawdataloaded; @@ -300,7 +277,7 @@ TIFFFillStripPartial( TIFF *tif, int strip, tmsize_t read_ahead, int restart ) /* For JPEG, if there are multiple scans (can generally be known */ /* with the read_ahead used), we need to read the whole strip */ if( tif->tif_dir.td_compression==COMPRESSION_JPEG && - (uint64)tif->tif_rawcc < TIFFGetStrileByteCount(tif, strip) ) + (uint64_t)tif->tif_rawcc < TIFFGetStrileByteCount(tif, strip) ) { if( TIFFJPEGIsFullStripRequired(tif) ) { @@ -326,10 +303,10 @@ TIFFFillStripPartial( TIFF *tif, int strip, tmsize_t read_ahead, int restart ) * strips. */ static int -TIFFSeek(TIFF* tif, uint32 row, uint16 sample ) +TIFFSeek(TIFF* tif, uint32_t row, uint16_t sample ) { register TIFFDirectory *td = &tif->tif_dir; - uint32 strip; + uint32_t strip; int whole_strip; tmsize_t read_ahead = 0; @@ -338,19 +315,19 @@ TIFFSeek(TIFF* tif, uint32 row, uint16 sample ) */ 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); + "%"PRIu32": Row out of range, max %"PRIu32"", + row, + td->td_imagelength); return (0); } if (td->td_planarconfig == PLANARCONFIG_SEPARATE) { if (sample >= td->td_samplesperpixel) { TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "%lu: Sample out of range, max %lu", - (unsigned long) sample, (unsigned long) td->td_samplesperpixel); + "%"PRIu16": Sample out of range, max %"PRIu16"", + sample, td->td_samplesperpixel); return (0); } - strip = (uint32)sample*td->td_stripsperimage + row/td->td_rowsperstrip; + strip = (uint32_t)sample * td->td_stripsperimage + row / td->td_rowsperstrip; } else strip = row / td->td_rowsperstrip; @@ -412,7 +389,7 @@ TIFFSeek(TIFF* tif, uint32 row, uint16 sample ) else if( !whole_strip ) { if( ((tif->tif_rawdata + tif->tif_rawdataloaded) - tif->tif_rawcp) < read_ahead - && (uint64) tif->tif_rawdataoff+tif->tif_rawdataloaded < TIFFGetStrileByteCount(tif, strip) ) + && (uint64_t) tif->tif_rawdataoff + tif->tif_rawdataloaded < TIFFGetStrileByteCount(tif, strip) ) { if( !TIFFFillStripPartial(tif,strip,read_ahead,0) ) return 0; @@ -457,7 +434,7 @@ TIFFSeek(TIFF* tif, uint32 row, uint16 sample ) } int -TIFFReadScanline(TIFF* tif, void* buf, uint32 row, uint16 sample) +TIFFReadScanline(TIFF* tif, void* buf, uint32_t row, uint16_t sample) { int e; @@ -468,13 +445,13 @@ TIFFReadScanline(TIFF* tif, void* buf, uint32 row, uint16 sample) * Decompress desired row into user buffer. */ e = (*tif->tif_decoderow) - (tif, (uint8*) buf, tif->tif_scanlinesize, sample); + (tif, (uint8_t*) buf, tif->tif_scanlinesize, sample); /* we are now poised at the beginning of the next row */ tif->tif_row = row + 1; if (e) - (*tif->tif_postdecode)(tif, (uint8*) buf, + (*tif->tif_postdecode)(tif, (uint8_t*) buf, tif->tif_scanlinesize); } return (e > 0 ? 1 : -1); @@ -485,22 +462,22 @@ TIFFReadScanline(TIFF* tif, void* buf, uint32 row, uint16 sample) * rows in the strip (check for truncated last strip on any * of the separations). */ -static tmsize_t TIFFReadEncodedStripGetStripSize(TIFF* tif, uint32 strip, uint16* pplane) +static tmsize_t TIFFReadEncodedStripGetStripSize(TIFF* tif, uint32_t strip, uint16_t* pplane) { static const char module[] = "TIFFReadEncodedStrip"; TIFFDirectory *td = &tif->tif_dir; - uint32 rowsperstrip; - uint32 stripsperplane; - uint32 stripinplane; - uint32 rows; + uint32_t rowsperstrip; + uint32_t stripsperplane; + uint32_t stripinplane; + uint32_t rows; tmsize_t stripsize; if (!TIFFCheckRead(tif,0)) return((tmsize_t)(-1)); if (strip>=td->td_nstrips) { TIFFErrorExt(tif->tif_clientdata,module, - "%lu: Strip out of range, max %lu",(unsigned long)strip, - (unsigned long)td->td_nstrips); + "%"PRIu32": Strip out of range, max %"PRIu32, strip, + td->td_nstrips); return((tmsize_t)(-1)); } @@ -509,7 +486,7 @@ static tmsize_t TIFFReadEncodedStripGetStripSize(TIFF* tif, uint32 strip, uint16 rowsperstrip=td->td_imagelength; stripsperplane= TIFFhowmany_32_maxuint_compat(td->td_imagelength, rowsperstrip); stripinplane=(strip%stripsperplane); - if( pplane ) *pplane=(uint16)(strip/stripsperplane); + if( pplane ) *pplane=(uint16_t)(strip / stripsperplane); rows=td->td_imagelength-stripinplane*rowsperstrip; if (rows>rowsperstrip) rows=rowsperstrip; @@ -524,12 +501,12 @@ static tmsize_t TIFFReadEncodedStripGetStripSize(TIFF* tif, uint32 strip, uint16 * amount into the user-supplied buffer. */ tmsize_t -TIFFReadEncodedStrip(TIFF* tif, uint32 strip, void* buf, tmsize_t size) +TIFFReadEncodedStrip(TIFF* tif, uint32_t strip, void* buf, tmsize_t size) { static const char module[] = "TIFFReadEncodedStrip"; TIFFDirectory *td = &tif->tif_dir; tmsize_t stripsize; - uint16 plane; + uint16_t plane; stripsize=TIFFReadEncodedStripGetStripSize(tif, strip, &plane); if (stripsize==((tmsize_t)(-1))) @@ -569,12 +546,12 @@ TIFFReadEncodedStrip(TIFF* tif, uint32 strip, void* buf, tmsize_t size) * * calls regular TIFFReadEncodedStrip() if *buf != NULL */ tmsize_t -_TIFFReadEncodedStripAndAllocBuffer(TIFF* tif, uint32 strip, +_TIFFReadEncodedStripAndAllocBuffer(TIFF* tif, uint32_t strip, void **buf, tmsize_t bufsizetoalloc, tmsize_t size_to_read) { tmsize_t this_stripsize; - uint16 plane; + uint16_t plane; if( *buf != NULL ) { @@ -606,8 +583,8 @@ _TIFFReadEncodedStripAndAllocBuffer(TIFF* tif, uint32 strip, } static tmsize_t -TIFFReadRawStrip1(TIFF* tif, uint32 strip, void* buf, tmsize_t size, - const char* module) +TIFFReadRawStrip1(TIFF* tif, uint32_t strip, void* buf, tmsize_t size, + const char* module) { assert((tif->tif_flags&TIFF_NOREADRAW)==0); if (!isMapped(tif)) { @@ -615,32 +592,24 @@ TIFFReadRawStrip1(TIFF* tif, uint32 strip, void* buf, tmsize_t size, if (!SeekOK(tif, TIFFGetStrileOffset(tif, strip))) { TIFFErrorExt(tif->tif_clientdata, module, - "Seek error at scanline %lu, strip %lu", - (unsigned long) tif->tif_row, (unsigned long) strip); + "Seek error at scanline %"PRIu32", strip %"PRIu32, + tif->tif_row, strip); return ((tmsize_t)(-1)); } cc = TIFFReadFile(tif, buf, size); if (cc != size) { -#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__)) TIFFErrorExt(tif->tif_clientdata, module, - "Read error at scanline %lu; got %I64u bytes, expected %I64u", - (unsigned long) tif->tif_row, - (unsigned __int64) cc, - (unsigned __int64) size); -#else - TIFFErrorExt(tif->tif_clientdata, module, - "Read error at scanline %lu; got %llu bytes, expected %llu", - (unsigned long) tif->tif_row, - (unsigned long long) cc, - (unsigned long long) size); -#endif + "Read error at scanline %"PRIu32"; got %"TIFF_SSIZE_FORMAT" bytes, expected %"TIFF_SSIZE_FORMAT, + tif->tif_row, + cc, + size); return ((tmsize_t)(-1)); } } else { tmsize_t ma = 0; tmsize_t n; - if ((TIFFGetStrileOffset(tif, strip) > (uint64)TIFF_TMSIZE_T_MAX)|| - ((ma=(tmsize_t)TIFFGetStrileOffset(tif, strip))>tif->tif_size)) + if ((TIFFGetStrileOffset(tif, strip) > (uint64_t)TIFF_TMSIZE_T_MAX) || + ((ma=(tmsize_t)TIFFGetStrileOffset(tif, strip))>tif->tif_size)) { n=0; } @@ -657,21 +626,12 @@ TIFFReadRawStrip1(TIFF* tif, uint32 strip, void* buf, tmsize_t size, n=size; } if (n!=size) { -#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__)) - TIFFErrorExt(tif->tif_clientdata, module, - "Read error at scanline %lu, strip %lu; got %I64u bytes, expected %I64u", - (unsigned long) tif->tif_row, - (unsigned long) strip, - (unsigned __int64) n, - (unsigned __int64) size); -#else TIFFErrorExt(tif->tif_clientdata, module, - "Read error at scanline %lu, strip %lu; got %llu bytes, expected %llu", - (unsigned long) tif->tif_row, - (unsigned long) strip, - (unsigned long long) n, - (unsigned long long) size); -#endif + "Read error at scanline %"PRIu32", strip %"PRIu32"; got %"TIFF_SSIZE_FORMAT" bytes, expected %"TIFF_SSIZE_FORMAT, + tif->tif_row, + strip, + n, + size); return ((tmsize_t)(-1)); } _TIFFmemcpy(buf, tif->tif_base + ma, @@ -681,7 +641,7 @@ TIFFReadRawStrip1(TIFF* tif, uint32 strip, void* buf, tmsize_t size, } static tmsize_t -TIFFReadRawStripOrTile2(TIFF* tif, uint32 strip_or_tile, int is_strip, +TIFFReadRawStripOrTile2(TIFF* tif, uint32_t strip_or_tile, int is_strip, tmsize_t size, const char* module) { assert( !isMapped(tif) ); @@ -691,17 +651,17 @@ TIFFReadRawStripOrTile2(TIFF* tif, uint32 strip_or_tile, int is_strip, if( is_strip ) { TIFFErrorExt(tif->tif_clientdata, module, - "Seek error at scanline %lu, strip %lu", - (unsigned long) tif->tif_row, - (unsigned long) strip_or_tile); + "Seek error at scanline %"PRIu32", strip %"PRIu32, + tif->tif_row, + strip_or_tile); } else { TIFFErrorExt(tif->tif_clientdata, module, - "Seek error at row %lu, col %lu, tile %lu", - (unsigned long) tif->tif_row, - (unsigned long) tif->tif_col, - (unsigned long) strip_or_tile); + "Seek error at row %"PRIu32", col %"PRIu32", tile %"PRIu32, + tif->tif_row, + tif->tif_col, + strip_or_tile); } return ((tmsize_t)(-1)); } @@ -719,20 +679,20 @@ TIFFReadRawStripOrTile2(TIFF* tif, uint32 strip_or_tile, int is_strip, * Read a strip of data from the file. */ tmsize_t -TIFFReadRawStrip(TIFF* tif, uint32 strip, void* buf, tmsize_t size) +TIFFReadRawStrip(TIFF* tif, uint32_t strip, void* buf, tmsize_t size) { static const char module[] = "TIFFReadRawStrip"; TIFFDirectory *td = &tif->tif_dir; - uint64 bytecount64; + uint64_t bytecount64; tmsize_t bytecountm; if (!TIFFCheckRead(tif, 0)) return ((tmsize_t)(-1)); if (strip >= td->td_nstrips) { TIFFErrorExt(tif->tif_clientdata, module, - "%lu: Strip out of range, max %lu", - (unsigned long) strip, - (unsigned long) td->td_nstrips); + "%"PRIu32": Strip out of range, max %"PRIu32, + strip, + td->td_nstrips); return ((tmsize_t)(-1)); } if (tif->tif_flags&TIFF_NOREADRAW) @@ -742,7 +702,7 @@ TIFFReadRawStrip(TIFF* tif, uint32 strip, void* buf, tmsize_t size) return ((tmsize_t)(-1)); } bytecount64 = TIFFGetStrileByteCount(tif, strip); - if (size != (tmsize_t)(-1) && (uint64)size <= bytecount64) + if (size != (tmsize_t)(-1) && (uint64_t)size <= bytecount64) bytecountm = size; else bytecountm = _TIFFCastUInt64ToSSize(tif, bytecount64, module); @@ -753,7 +713,7 @@ TIFFReadRawStrip(TIFF* tif, uint32 strip, void* buf, tmsize_t size) } TIFF_NOSANITIZE_UNSIGNED_INT_OVERFLOW -static uint64 NoSanitizeSubUInt64(uint64 a, uint64 b) +static uint64_t NoSanitizeSubUInt64(uint64_t a, uint64_t b) { return a - b; } @@ -763,26 +723,19 @@ static uint64 NoSanitizeSubUInt64(uint64 a, uint64 b) * expanded, as necessary, to hold the strip's data. */ int -TIFFFillStrip(TIFF* tif, uint32 strip) +TIFFFillStrip(TIFF* tif, uint32_t strip) { static const char module[] = "TIFFFillStrip"; TIFFDirectory *td = &tif->tif_dir; if ((tif->tif_flags&TIFF_NOREADRAW)==0) { - uint64 bytecount = TIFFGetStrileByteCount(tif, strip); - if( bytecount == 0 || bytecount > (uint64)TIFF_INT64_MAX ) { -#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__)) - TIFFErrorExt(tif->tif_clientdata, module, - "Invalid strip byte count %I64u, strip %lu", - (unsigned __int64) bytecount, - (unsigned long) strip); -#else + uint64_t bytecount = TIFFGetStrileByteCount(tif, strip); + if( bytecount == 0 || bytecount > (uint64_t)TIFF_INT64_MAX ) { TIFFErrorExt(tif->tif_clientdata, module, - "Invalid strip byte count %llu, strip %lu", - (unsigned long long) bytecount, - (unsigned long) strip); -#endif + "Invalid strip byte count %"PRIu64", strip %"PRIu32, + bytecount, + strip); return (0); } @@ -795,24 +748,16 @@ TIFFFillStrip(TIFF* tif, uint32 strip) /* Hopefully they are safe enough for all codecs */ tmsize_t stripsize = TIFFStripSize(tif); if( stripsize != 0 && - (bytecount - 4096) / 10 > (uint64)stripsize ) + (bytecount - 4096) / 10 > (uint64_t)stripsize ) { - uint64 newbytecount = (uint64)stripsize * 10 + 4096; - if( newbytecount == 0 || newbytecount > (uint64)TIFF_INT64_MAX ) + uint64_t newbytecount = (uint64_t)stripsize * 10 + 4096; + if( newbytecount == 0 || newbytecount > (uint64_t)TIFF_INT64_MAX ) { -#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__)) - TIFFWarningExt(tif->tif_clientdata, module, - "Too large strip byte count %I64u, strip %lu. Limiting to %I64u", - (unsigned __int64) bytecount, - (unsigned long) strip, - (unsigned __int64) newbytecount); -#else TIFFErrorExt(tif->tif_clientdata, module, - "Too large strip byte count %llu, strip %lu. Limiting to %llu", - (unsigned long long) bytecount, - (unsigned long) strip, - (unsigned long long) newbytecount); -#endif + "Too large strip byte count %"PRIu64", strip %"PRIu32". Limiting to %"PRIu64, + bytecount, + strip, + newbytecount); bytecount = newbytecount; } } @@ -828,30 +773,20 @@ TIFFFillStrip(TIFF* tif, uint32 strip) * comparison (which can overflow) we do the following * two comparisons: */ - if (bytecount > (uint64)tif->tif_size || - TIFFGetStrileOffset(tif, strip) > (uint64)tif->tif_size - bytecount) { + if (bytecount > (uint64_t)tif->tif_size || + TIFFGetStrileOffset(tif, strip) > (uint64_t)tif->tif_size - bytecount) { /* * This error message might seem strange, but * it's what would happen if a read were done * instead. */ -#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__)) - TIFFErrorExt(tif->tif_clientdata, module, - - "Read error on strip %lu; " - "got %I64u bytes, expected %I64u", - (unsigned long) strip, - (unsigned __int64) NoSanitizeSubUInt64(tif->tif_size, TIFFGetStrileOffset(tif, strip)), - (unsigned __int64) bytecount); -#else TIFFErrorExt(tif->tif_clientdata, module, - "Read error on strip %lu; " - "got %llu bytes, expected %llu", - (unsigned long) strip, - (unsigned long long) NoSanitizeSubUInt64(tif->tif_size, TIFFGetStrileOffset(tif, strip)), - (unsigned long long) bytecount); -#endif + "Read error on strip %"PRIu32"; " + "got %"PRIu64" bytes, expected %"PRIu64, + strip, + NoSanitizeSubUInt64(tif->tif_size, TIFFGetStrileOffset(tif, strip)), + bytecount); tif->tif_curstrip = NOSTRIP; return (0); } @@ -897,7 +832,7 @@ TIFFFillStrip(TIFF* tif, uint32 strip) */ tmsize_t bytecountm; bytecountm=(tmsize_t)bytecount; - if ((uint64)bytecountm!=bytecount) + if ((uint64_t)bytecountm != bytecount) { TIFFErrorExt(tif->tif_clientdata,module,"Integer overflow"); return(0); @@ -906,8 +841,8 @@ TIFFFillStrip(TIFF* tif, uint32 strip) tif->tif_curstrip = NOSTRIP; if ((tif->tif_flags & TIFF_MYBUFFER) == 0) { TIFFErrorExt(tif->tif_clientdata, module, - "Data buffer too small to hold strip %lu", - (unsigned long) strip); + "Data buffer too small to hold strip %"PRIu32, + strip); return (0); } } @@ -962,7 +897,7 @@ TIFFFillStrip(TIFF* tif, uint32 strip) * tile is selected by the (x,y,z,s) coordinates. */ tmsize_t -TIFFReadTile(TIFF* tif, void* buf, uint32 x, uint32 y, uint32 z, uint16 s) +TIFFReadTile(TIFF* tif, void* buf, uint32_t x, uint32_t y, uint32_t z, uint16_t s) { if (!TIFFCheckRead(tif, 1) || !TIFFCheckTile(tif, x, y, z, s)) return ((tmsize_t)(-1)); @@ -975,7 +910,7 @@ TIFFReadTile(TIFF* tif, void* buf, uint32 x, uint32 y, uint32 z, uint16 s) * amount into the user-supplied buffer. */ tmsize_t -TIFFReadEncodedTile(TIFF* tif, uint32 tile, void* buf, tmsize_t size) +TIFFReadEncodedTile(TIFF* tif, uint32_t tile, void* buf, tmsize_t size) { static const char module[] = "TIFFReadEncodedTile"; TIFFDirectory *td = &tif->tif_dir; @@ -985,8 +920,8 @@ TIFFReadEncodedTile(TIFF* tif, uint32 tile, void* buf, tmsize_t size) return ((tmsize_t)(-1)); if (tile >= td->td_nstrips) { TIFFErrorExt(tif->tif_clientdata, module, - "%lu: Tile out of range, max %lu", - (unsigned long) tile, (unsigned long) td->td_nstrips); + "%"PRIu32": Tile out of range, max %"PRIu32, + tile, td->td_nstrips); return ((tmsize_t)(-1)); } @@ -1012,8 +947,8 @@ TIFFReadEncodedTile(TIFF* tif, uint32 tile, void* buf, tmsize_t size) else if (size > tilesize) size = tilesize; if (TIFFFillTile(tif, tile) && (*tif->tif_decodetile)(tif, - (uint8*) buf, size, (uint16)(tile/td->td_stripsperimage))) { - (*tif->tif_postdecode)(tif, (uint8*) buf, size); + (uint8_t*) buf, size, (uint16_t)(tile / td->td_stripsperimage))) { + (*tif->tif_postdecode)(tif, (uint8_t*) buf, size); return (size); } else return ((tmsize_t)(-1)); @@ -1028,7 +963,7 @@ TIFFReadEncodedTile(TIFF* tif, uint32 tile, void* buf, tmsize_t size) tmsize_t _TIFFReadTileAndAllocBuffer(TIFF* tif, void **buf, tmsize_t bufsizetoalloc, - uint32 x, uint32 y, uint32 z, uint16 s) + uint32_t x, uint32_t y, uint32_t z, uint16_t s) { if (!TIFFCheckRead(tif, 1) || !TIFFCheckTile(tif, x, y, z, s)) return ((tmsize_t)(-1)); @@ -1045,9 +980,9 @@ _TIFFReadTileAndAllocBuffer(TIFF* tif, * * calls regular TIFFReadEncodedTile() if *buf != NULL */ tmsize_t -_TIFFReadEncodedTileAndAllocBuffer(TIFF* tif, uint32 tile, - void **buf, tmsize_t bufsizetoalloc, - tmsize_t size_to_read) +_TIFFReadEncodedTileAndAllocBuffer(TIFF* tif, uint32_t tile, + void **buf, tmsize_t bufsizetoalloc, + tmsize_t size_to_read) { static const char module[] = "_TIFFReadEncodedTileAndAllocBuffer"; TIFFDirectory *td = &tif->tif_dir; @@ -1062,8 +997,8 @@ _TIFFReadEncodedTileAndAllocBuffer(TIFF* tif, uint32 tile, return ((tmsize_t)(-1)); if (tile >= td->td_nstrips) { TIFFErrorExt(tif->tif_clientdata, module, - "%lu: Tile out of range, max %lu", - (unsigned long) tile, (unsigned long) td->td_nstrips); + "%"PRIu32": Tile out of range, max %"PRIu32, + tile, td->td_nstrips); return ((tmsize_t)(-1)); } @@ -1083,15 +1018,15 @@ _TIFFReadEncodedTileAndAllocBuffer(TIFF* tif, uint32 tile, else if (size_to_read > tilesize) size_to_read = tilesize; if( (*tif->tif_decodetile)(tif, - (uint8*) *buf, size_to_read, (uint16)(tile/td->td_stripsperimage))) { - (*tif->tif_postdecode)(tif, (uint8*) *buf, size_to_read); + (uint8_t*) *buf, size_to_read, (uint16_t)(tile / td->td_stripsperimage))) { + (*tif->tif_postdecode)(tif, (uint8_t*) *buf, size_to_read); return (size_to_read); } else return ((tmsize_t)(-1)); } static tmsize_t -TIFFReadRawTile1(TIFF* tif, uint32 tile, void* buf, tmsize_t size, const char* module) +TIFFReadRawTile1(TIFF* tif, uint32_t tile, void* buf, tmsize_t size, const char* module) { assert((tif->tif_flags&TIFF_NOREADRAW)==0); if (!isMapped(tif)) { @@ -1099,29 +1034,20 @@ TIFFReadRawTile1(TIFF* tif, uint32 tile, void* buf, tmsize_t size, const char* m if (!SeekOK(tif, TIFFGetStrileOffset(tif, tile))) { TIFFErrorExt(tif->tif_clientdata, module, - "Seek error at row %lu, col %lu, tile %lu", - (unsigned long) tif->tif_row, - (unsigned long) tif->tif_col, - (unsigned long) tile); + "Seek error at row %"PRIu32", col %"PRIu32", tile %"PRIu32, + tif->tif_row, + tif->tif_col, + tile); return ((tmsize_t)(-1)); } cc = TIFFReadFile(tif, buf, size); if (cc != size) { -#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__)) - TIFFErrorExt(tif->tif_clientdata, module, - "Read error at row %lu, col %lu; got %I64u bytes, expected %I64u", - (unsigned long) tif->tif_row, - (unsigned long) tif->tif_col, - (unsigned __int64) cc, - (unsigned __int64) size); -#else TIFFErrorExt(tif->tif_clientdata, module, - "Read error at row %lu, col %lu; got %llu bytes, expected %llu", - (unsigned long) tif->tif_row, - (unsigned long) tif->tif_col, - (unsigned long long) cc, - (unsigned long long) size); -#endif + "Read error at row %"PRIu32", col %"PRIu32"; got %"TIFF_SSIZE_FORMAT" bytes, expected %"TIFF_SSIZE_FORMAT, + tif->tif_row, + tif->tif_col, + cc, + size); return ((tmsize_t)(-1)); } } else { @@ -1129,30 +1055,20 @@ TIFFReadRawTile1(TIFF* tif, uint32 tile, void* buf, tmsize_t size, const char* m tmsize_t n; ma=(tmsize_t)TIFFGetStrileOffset(tif, tile); mb=ma+size; - if ((TIFFGetStrileOffset(tif, tile) > (uint64)TIFF_TMSIZE_T_MAX)||(ma>tif->tif_size)) + if ((TIFFGetStrileOffset(tif, tile) > (uint64_t)TIFF_TMSIZE_T_MAX) || (ma > tif->tif_size)) n=0; else if ((mb<ma)||(mb<size)||(mb>tif->tif_size)) n=tif->tif_size-ma; else n=size; if (n!=size) { -#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__)) - TIFFErrorExt(tif->tif_clientdata, module, -"Read error at row %lu, col %lu, tile %lu; got %I64u bytes, expected %I64u", - (unsigned long) tif->tif_row, - (unsigned long) tif->tif_col, - (unsigned long) tile, - (unsigned __int64) n, - (unsigned __int64) size); -#else TIFFErrorExt(tif->tif_clientdata, module, -"Read error at row %lu, col %lu, tile %lu; got %llu bytes, expected %llu", - (unsigned long) tif->tif_row, - (unsigned long) tif->tif_col, - (unsigned long) tile, - (unsigned long long) n, - (unsigned long long) size); -#endif +"Read error at row %"PRIu32", col %"PRIu32", tile %"PRIu32"; got %"TIFF_SSIZE_FORMAT" bytes, expected %"TIFF_SSIZE_FORMAT, + tif->tif_row, + tif->tif_col, + tile, + n, + size); return ((tmsize_t)(-1)); } _TIFFmemcpy(buf, tif->tif_base + ma, size); @@ -1164,19 +1080,19 @@ TIFFReadRawTile1(TIFF* tif, uint32 tile, void* buf, tmsize_t size, const char* m * Read a tile of data from the file. */ tmsize_t -TIFFReadRawTile(TIFF* tif, uint32 tile, void* buf, tmsize_t size) +TIFFReadRawTile(TIFF* tif, uint32_t tile, void* buf, tmsize_t size) { static const char module[] = "TIFFReadRawTile"; TIFFDirectory *td = &tif->tif_dir; - uint64 bytecount64; + uint64_t bytecount64; tmsize_t bytecountm; if (!TIFFCheckRead(tif, 1)) return ((tmsize_t)(-1)); if (tile >= td->td_nstrips) { TIFFErrorExt(tif->tif_clientdata, module, - "%lu: Tile out of range, max %lu", - (unsigned long) tile, (unsigned long) td->td_nstrips); + "%"PRIu32": Tile out of range, max %"PRIu32, + tile, td->td_nstrips); return ((tmsize_t)(-1)); } if (tif->tif_flags&TIFF_NOREADRAW) @@ -1186,7 +1102,7 @@ TIFFReadRawTile(TIFF* tif, uint32 tile, void* buf, tmsize_t size) return ((tmsize_t)(-1)); } bytecount64 = TIFFGetStrileByteCount(tif, tile); - if (size != (tmsize_t)(-1) && (uint64)size <= bytecount64) + if (size != (tmsize_t)(-1) && (uint64_t)size <= bytecount64) bytecountm = size; else bytecountm = _TIFFCastUInt64ToSSize(tif, bytecount64, module); @@ -1201,26 +1117,19 @@ TIFFReadRawTile(TIFF* tif, uint32 tile, void* buf, tmsize_t size) * expanded, as necessary, to hold the tile's data. */ int -TIFFFillTile(TIFF* tif, uint32 tile) +TIFFFillTile(TIFF* tif, uint32_t tile) { static const char module[] = "TIFFFillTile"; TIFFDirectory *td = &tif->tif_dir; if ((tif->tif_flags&TIFF_NOREADRAW)==0) { - uint64 bytecount = TIFFGetStrileByteCount(tif, tile); - if( bytecount == 0 || bytecount > (uint64)TIFF_INT64_MAX ) { -#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__)) + uint64_t bytecount = TIFFGetStrileByteCount(tif, tile); + if( bytecount == 0 || bytecount > (uint64_t)TIFF_INT64_MAX ) { TIFFErrorExt(tif->tif_clientdata, module, - "%I64u: Invalid tile byte count, tile %lu", - (unsigned __int64) bytecount, - (unsigned long) tile); -#else - TIFFErrorExt(tif->tif_clientdata, module, - "%llu: Invalid tile byte count, tile %lu", - (unsigned long long) bytecount, - (unsigned long) tile); -#endif + "%"PRIu64": Invalid tile byte count, tile %"PRIu32, + bytecount, + tile); return (0); } @@ -1233,24 +1142,16 @@ TIFFFillTile(TIFF* tif, uint32 tile) /* Hopefully they are safe enough for all codecs */ tmsize_t stripsize = TIFFTileSize(tif); if( stripsize != 0 && - (bytecount - 4096) / 10 > (uint64)stripsize ) + (bytecount - 4096) / 10 > (uint64_t)stripsize ) { - uint64 newbytecount = (uint64)stripsize * 10 + 4096; - if( newbytecount == 0 || newbytecount > (uint64)TIFF_INT64_MAX ) + uint64_t newbytecount = (uint64_t)stripsize * 10 + 4096; + if( newbytecount == 0 || newbytecount > (uint64_t)TIFF_INT64_MAX ) { -#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__)) - TIFFWarningExt(tif->tif_clientdata, module, - "Too large tile byte count %I64u, tile %lu. Limiting to %I64u", - (unsigned __int64) bytecount, - (unsigned long) tile, - (unsigned __int64) newbytecount); -#else TIFFErrorExt(tif->tif_clientdata, module, - "Too large tile byte count %llu, tile %lu. Limiting to %llu", - (unsigned long long) bytecount, - (unsigned long) tile, - (unsigned long long) newbytecount); -#endif + "Too large tile byte count %"PRIu64", tile %"PRIu32". Limiting to %"PRIu64, + bytecount, + tile, + newbytecount); bytecount = newbytecount; } } @@ -1266,8 +1167,8 @@ TIFFFillTile(TIFF* tif, uint32 tile) * comparison (which can overflow) we do the following * two comparisons: */ - if (bytecount > (uint64)tif->tif_size || - TIFFGetStrileOffset(tif, tile) > (uint64)tif->tif_size - bytecount) { + if (bytecount > (uint64_t)tif->tif_size || + TIFFGetStrileOffset(tif, tile) > (uint64_t)tif->tif_size - bytecount) { tif->tif_curtile = NOTILE; return (0); } @@ -1308,7 +1209,7 @@ TIFFFillTile(TIFF* tif, uint32 tile) */ tmsize_t bytecountm; bytecountm=(tmsize_t)bytecount; - if ((uint64)bytecountm!=bytecount) + if ((uint64_t)bytecountm != bytecount) { TIFFErrorExt(tif->tif_clientdata,module,"Integer overflow"); return(0); @@ -1317,8 +1218,8 @@ TIFFFillTile(TIFF* tif, uint32 tile) tif->tif_curtile = NOTILE; if ((tif->tif_flags & TIFF_MYBUFFER) == 0) { TIFFErrorExt(tif->tif_clientdata, module, - "Data buffer too small to hold tile %lu", - (unsigned long) tile); + "Data buffer too small to hold tile %"PRIu32, + tile); return (0); } } @@ -1390,10 +1291,10 @@ TIFFReadBufferSetup(TIFF* tif, void* bp, tmsize_t size) } if (bp) { tif->tif_rawdatasize = size; - tif->tif_rawdata = (uint8*) bp; + tif->tif_rawdata = (uint8_t*) bp; tif->tif_flags &= ~TIFF_MYBUFFER; } else { - tif->tif_rawdatasize = (tmsize_t)TIFFroundup_64((uint64)size, 1024); + tif->tif_rawdatasize = (tmsize_t)TIFFroundup_64((uint64_t)size, 1024); if (tif->tif_rawdatasize==0) { TIFFErrorExt(tif->tif_clientdata, module, "Invalid buffer size"); @@ -1401,13 +1302,13 @@ TIFFReadBufferSetup(TIFF* tif, void* bp, tmsize_t size) } /* Initialize to zero to avoid uninitialized buffers in case of */ /* short reads (http://bugzilla.maptools.org/show_bug.cgi?id=2651) */ - tif->tif_rawdata = (uint8*) _TIFFcalloc(1, tif->tif_rawdatasize); + tif->tif_rawdata = (uint8_t*) _TIFFcalloc(1, tif->tif_rawdatasize); tif->tif_flags |= TIFF_MYBUFFER; } if (tif->tif_rawdata == NULL) { TIFFErrorExt(tif->tif_clientdata, module, - "No space for data buffer at scanline %lu", - (unsigned long) tif->tif_row); + "No space for data buffer at scanline %"PRIu32, + tif->tif_row); tif->tif_rawdatasize = 0; return (0); } @@ -1419,7 +1320,7 @@ TIFFReadBufferSetup(TIFF* tif, void* bp, tmsize_t size) * strip has just been read in. */ static int -TIFFStartStrip(TIFF* tif, uint32 strip) +TIFFStartStrip(TIFF* tif, uint32_t strip) { TIFFDirectory *td = &tif->tif_dir; @@ -1446,7 +1347,7 @@ TIFFStartStrip(TIFF* tif, uint32 strip) tif->tif_rawcc = (tmsize_t)TIFFGetStrileByteCount(tif, strip); } if ((*tif->tif_predecode)(tif, - (uint16)(strip / td->td_stripsperimage)) == 0 ) { + (uint16_t)(strip / td->td_stripsperimage)) == 0 ) { /* Needed for example for scanline access, if tif_predecode */ /* fails, and we try to read the same strip again. Without invalidating */ /* tif_curstrip, we'd call tif_decoderow() on a possibly invalid */ @@ -1462,11 +1363,11 @@ TIFFStartStrip(TIFF* tif, uint32 strip) * tile has just been read in. */ static int -TIFFStartTile(TIFF* tif, uint32 tile) +TIFFStartTile(TIFF* tif, uint32_t tile) { static const char module[] = "TIFFStartTile"; TIFFDirectory *td = &tif->tif_dir; - uint32 howmany32; + uint32_t howmany32; if ((tif->tif_flags & TIFF_CODERSETUP) == 0) { if (!(*tif->tif_setupdecode)(tif)) @@ -1501,7 +1402,7 @@ TIFFStartTile(TIFF* tif, uint32 tile) tif->tif_rawcc = (tmsize_t)TIFFGetStrileByteCount(tif, tile); } return ((*tif->tif_predecode)(tif, - (uint16)(tile/td->td_stripsperimage))); + (uint16_t)(tile / td->td_stripsperimage))); } static int @@ -1529,14 +1430,14 @@ TIFFCheckRead(TIFF* tif, int tiles) * inbuf content must be writable (if bit reversal is needed) * Returns 1 in case of success, 0 otherwise. */ -int TIFFReadFromUserBuffer(TIFF* tif, uint32 strile, +int TIFFReadFromUserBuffer(TIFF* tif, uint32_t strile, void* inbuf, tmsize_t insize, void* outbuf, tmsize_t outsize) { static const char module[] = "TIFFReadFromUserBuffer"; TIFFDirectory *td = &tif->tif_dir; int ret = 1; - uint32 old_tif_flags = tif->tif_flags; + uint32_t old_tif_flags = tif->tif_flags; tmsize_t old_rawdatasize = tif->tif_rawdatasize; void* old_rawdata = tif->tif_rawdata; @@ -1567,29 +1468,29 @@ int TIFFReadFromUserBuffer(TIFF* tif, uint32 strile, if( TIFFIsTiled(tif) ) { if( !TIFFStartTile(tif, strile) || - !(*tif->tif_decodetile)(tif, (uint8*) outbuf, outsize, - (uint16)(strile/td->td_stripsperimage)) ) + !(*tif->tif_decodetile)(tif, (uint8_t*) outbuf, outsize, + (uint16_t)(strile / td->td_stripsperimage)) ) { ret = 0; } } else { - uint32 rowsperstrip=td->td_rowsperstrip; - uint32 stripsperplane; + uint32_t rowsperstrip=td->td_rowsperstrip; + uint32_t stripsperplane; if (rowsperstrip>td->td_imagelength) rowsperstrip=td->td_imagelength; stripsperplane= TIFFhowmany_32_maxuint_compat(td->td_imagelength, rowsperstrip); if( !TIFFStartStrip(tif, strile) || - !(*tif->tif_decodestrip)(tif, (uint8*) outbuf, outsize, - (uint16)(strile/stripsperplane)) ) + !(*tif->tif_decodestrip)(tif, (uint8_t*) outbuf, outsize, + (uint16_t)(strile / stripsperplane)) ) { ret = 0; } } if( ret ) { - (*tif->tif_postdecode)(tif, (uint8*) outbuf, outsize); + (*tif->tif_postdecode)(tif, (uint8_t*) outbuf, outsize); } if (!isFillOrder(tif, td->td_fillorder) && @@ -1608,37 +1509,37 @@ int TIFFReadFromUserBuffer(TIFF* tif, uint32 strile, } void -_TIFFNoPostDecode(TIFF* tif, uint8* buf, tmsize_t cc) +_TIFFNoPostDecode(TIFF* tif, uint8_t* buf, tmsize_t cc) { (void) tif; (void) buf; (void) cc; } void -_TIFFSwab16BitData(TIFF* tif, uint8* buf, tmsize_t cc) +_TIFFSwab16BitData(TIFF* tif, uint8_t* buf, tmsize_t cc) { (void) tif; assert((cc & 1) == 0); - TIFFSwabArrayOfShort((uint16*) buf, cc/2); + TIFFSwabArrayOfShort((uint16_t*) buf, cc / 2); } void -_TIFFSwab24BitData(TIFF* tif, uint8* buf, tmsize_t cc) +_TIFFSwab24BitData(TIFF* tif, uint8_t* buf, tmsize_t cc) { (void) tif; assert((cc % 3) == 0); - TIFFSwabArrayOfTriples((uint8*) buf, cc/3); + TIFFSwabArrayOfTriples((uint8_t*) buf, cc / 3); } void -_TIFFSwab32BitData(TIFF* tif, uint8* buf, tmsize_t cc) +_TIFFSwab32BitData(TIFF* tif, uint8_t* buf, tmsize_t cc) { (void) tif; assert((cc & 3) == 0); - TIFFSwabArrayOfLong((uint32*) buf, cc/4); + TIFFSwabArrayOfLong((uint32_t*) buf, cc / 4); } void -_TIFFSwab64BitData(TIFF* tif, uint8* buf, tmsize_t cc) +_TIFFSwab64BitData(TIFF* tif, uint8_t* buf, tmsize_t cc) { (void) tif; assert((cc & 7) == 0); diff --git a/tiff/libtiff/tif_stream.cxx b/tiff/libtiff/tif_stream.cxx index 7f640a9c..ea224169 100644 --- a/tiff/libtiff/tif_stream.cxx +++ b/tiff/libtiff/tif_stream.cxx @@ -28,9 +28,7 @@ #include "tiffiop.h" #include <iostream> -#ifndef __VMS using namespace std; -#endif /* ISO C++ uses a 'std::streamsize' type to define counts. This makes @@ -82,10 +80,10 @@ extern "C" { static tmsize_t _tiffisReadProc(thandle_t fd, void* buf, tmsize_t size); static tmsize_t _tiffosWriteProc(thandle_t fd, void* buf, tmsize_t size); static tmsize_t _tiffisWriteProc(thandle_t, void*, tmsize_t); - static uint64 _tiffosSeekProc(thandle_t fd, uint64 off, int whence); - static uint64 _tiffisSeekProc(thandle_t fd, uint64 off, int whence); - static uint64 _tiffosSizeProc(thandle_t fd); - static uint64 _tiffisSizeProc(thandle_t fd); + static uint64_t _tiffosSeekProc(thandle_t fd, uint64_t off, int whence); + static uint64_t _tiffisSeekProc(thandle_t fd, uint64_t off, int whence); + static uint64_t _tiffosSizeProc(thandle_t fd); + static uint64_t _tiffisSizeProc(thandle_t fd); static int _tiffosCloseProc(thandle_t fd); static int _tiffisCloseProc(thandle_t fd); static int _tiffDummyMapProc(thandle_t , void** base, toff_t* size ); @@ -148,26 +146,26 @@ _tiffisWriteProc(thandle_t, void*, tmsize_t) return 0; } -static uint64 -_tiffosSeekProc(thandle_t fd, uint64 off, int whence) +static uint64_t +_tiffosSeekProc(thandle_t fd, uint64_t off, int whence) { tiffos_data *data = reinterpret_cast<tiffos_data *>(fd); ostream *os = data->stream; // if the stream has already failed, don't do anything if( os->fail() ) - return static_cast<uint64>(-1); + return static_cast<uint64_t>(-1); switch(whence) { case SEEK_SET: { // Compute 64-bit offset - uint64 new_offset = static_cast<uint64>(data->start_pos) + off; + uint64_t new_offset = static_cast<uint64_t>(data->start_pos) + off; // Verify that value does not overflow ios::off_type offset = static_cast<ios::off_type>(new_offset); - if (static_cast<uint64>(offset) != new_offset) - return static_cast<uint64>(-1); + if (static_cast<uint64_t>(offset) != new_offset) + return static_cast<uint64_t>(-1); os->seekp(offset, ios::beg); break; @@ -176,8 +174,8 @@ _tiffosSeekProc(thandle_t fd, uint64 off, int whence) { // Verify that value does not overflow ios::off_type offset = static_cast<ios::off_type>(off); - if (static_cast<uint64>(offset) != off) - return static_cast<uint64>(-1); + if (static_cast<uint64_t>(offset) != off) + return static_cast<uint64_t>(-1); os->seekp(offset, ios::cur); break; @@ -186,8 +184,8 @@ _tiffosSeekProc(thandle_t fd, uint64 off, int whence) { // Verify that value does not overflow ios::off_type offset = static_cast<ios::off_type>(off); - if (static_cast<uint64>(offset) != off) - return static_cast<uint64>(-1); + if (static_cast<uint64_t>(offset) != off) + return static_cast<uint64_t>(-1); os->seekp(offset, ios::end); break; @@ -199,11 +197,7 @@ _tiffosSeekProc(thandle_t fd, uint64 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; -#endif ios::pos_type origin; old_state = os->rdstate(); @@ -226,28 +220,28 @@ _tiffosSeekProc(thandle_t fd, uint64 off, int whence) os->clear(old_state); // only do something if desired seek position is valid - if( (static_cast<uint64>(origin) + off) > static_cast<uint64>(data->start_pos) ) { - uint64 num_fill; + if((static_cast<uint64_t>(origin) + off) > static_cast<uint64_t>(data->start_pos) ) { + uint64_t num_fill; // clear the fail bit os->clear(os->rdstate() & ~ios::failbit); // extend the stream to the expected size os->seekp(0, ios::end); - num_fill = (static_cast<uint64>(origin)) + off - os->tellp(); - for( uint64 i = 0; i < num_fill; i++ ) + num_fill = (static_cast<uint64_t>(origin)) + off - os->tellp(); + for(uint64_t i = 0; i < num_fill; i++ ) os->put('\0'); // retry the seek - os->seekp(static_cast<ios::off_type>(static_cast<uint64>(origin) + off), ios::beg); + os->seekp(static_cast<ios::off_type>(static_cast<uint64_t>(origin) + off), ios::beg); } } - return static_cast<uint64>(os->tellp()); + return static_cast<uint64_t>(os->tellp()); } -static uint64 -_tiffisSeekProc(thandle_t fd, uint64 off, int whence) +static uint64_t +_tiffisSeekProc(thandle_t fd, uint64_t off, int whence) { tiffis_data *data = reinterpret_cast<tiffis_data *>(fd); @@ -255,12 +249,12 @@ _tiffisSeekProc(thandle_t fd, uint64 off, int whence) case SEEK_SET: { // Compute 64-bit offset - uint64 new_offset = static_cast<uint64>(data->start_pos) + off; + uint64_t new_offset = static_cast<uint64_t>(data->start_pos) + off; // Verify that value does not overflow ios::off_type offset = static_cast<ios::off_type>(new_offset); - if (static_cast<uint64>(offset) != new_offset) - return static_cast<uint64>(-1); + if (static_cast<uint64_t>(offset) != new_offset) + return static_cast<uint64_t>(-1); data->stream->seekg(offset, ios::beg); break; @@ -269,8 +263,8 @@ _tiffisSeekProc(thandle_t fd, uint64 off, int whence) { // Verify that value does not overflow ios::off_type offset = static_cast<ios::off_type>(off); - if (static_cast<uint64>(offset) != off) - return static_cast<uint64>(-1); + if (static_cast<uint64_t>(offset) != off) + return static_cast<uint64_t>(-1); data->stream->seekg(offset, ios::cur); break; @@ -279,18 +273,18 @@ _tiffisSeekProc(thandle_t fd, uint64 off, int whence) { // Verify that value does not overflow ios::off_type offset = static_cast<ios::off_type>(off); - if (static_cast<uint64>(offset) != off) - return static_cast<uint64>(-1); + if (static_cast<uint64_t>(offset) != off) + return static_cast<uint64_t>(-1); data->stream->seekg(offset, ios::end); break; } } - return (uint64) (data->stream->tellg() - data->start_pos); + return (uint64_t) (data->stream->tellg() - data->start_pos); } -static uint64 +static uint64_t _tiffosSizeProc(thandle_t fd) { tiffos_data *data = reinterpret_cast<tiffos_data *>(fd); @@ -302,10 +296,10 @@ _tiffosSizeProc(thandle_t fd) len = os->tellp(); os->seekp(pos); - return (uint64) len; + return (uint64_t) len; } -static uint64 +static uint64_t _tiffisSizeProc(thandle_t fd) { tiffis_data *data = reinterpret_cast<tiffis_data *>(fd); @@ -316,7 +310,7 @@ _tiffisSizeProc(thandle_t fd) len = data->stream->tellg(); data->stream->seekg(pos); - return (uint64) len; + return (uint64_t) len; } static int diff --git a/tiff/libtiff/tif_strip.c b/tiff/libtiff/tif_strip.c index c08c60a7..d7b27526 100644 --- a/tiff/libtiff/tif_strip.c +++ b/tiff/libtiff/tif_strip.c @@ -32,12 +32,12 @@ /* * Compute which strip a (row,sample) value is in. */ -uint32 -TIFFComputeStrip(TIFF* tif, uint32 row, uint16 sample) +uint32_t +TIFFComputeStrip(TIFF* tif, uint32_t row, uint16_t sample) { static const char module[] = "TIFFComputeStrip"; TIFFDirectory *td = &tif->tif_dir; - uint32 strip; + uint32_t strip; strip = row / td->td_rowsperstrip; if (td->td_planarconfig == PLANARCONFIG_SEPARATE) { @@ -47,7 +47,7 @@ TIFFComputeStrip(TIFF* tif, uint32 row, uint16 sample) (unsigned long) sample, (unsigned long) td->td_samplesperpixel); return (0); } - strip += (uint32)sample*td->td_stripsperimage; + strip += (uint32_t)sample * td->td_stripsperimage; } return (strip); } @@ -55,16 +55,16 @@ TIFFComputeStrip(TIFF* tif, uint32 row, uint16 sample) /* * Compute how many strips are in an image. */ -uint32 +uint32_t TIFFNumberOfStrips(TIFF* tif) { TIFFDirectory *td = &tif->tif_dir; - uint32 nstrips; + uint32_t nstrips; - nstrips = (td->td_rowsperstrip == (uint32) -1 ? 1 : - TIFFhowmany_32(td->td_imagelength, td->td_rowsperstrip)); + nstrips = (td->td_rowsperstrip == (uint32_t) -1 ? 1 : + TIFFhowmany_32(td->td_imagelength, td->td_rowsperstrip)); if (td->td_planarconfig == PLANARCONFIG_SEPARATE) - nstrips = _TIFFMultiply32(tif, nstrips, (uint32)td->td_samplesperpixel, + nstrips = _TIFFMultiply32(tif, nstrips, (uint32_t)td->td_samplesperpixel, "TIFFNumberOfStrips"); return (nstrips); } @@ -72,12 +72,12 @@ TIFFNumberOfStrips(TIFF* tif) /* * Compute the # bytes in a variable height, row-aligned strip. */ -uint64 -TIFFVStripSize64(TIFF* tif, uint32 nrows) +uint64_t +TIFFVStripSize64(TIFF* tif, uint32_t nrows) { static const char module[] = "TIFFVStripSize64"; TIFFDirectory *td = &tif->tif_dir; - if (nrows==(uint32)(-1)) + if (nrows==(uint32_t)(-1)) nrows=td->td_imagelength; if ((td->td_planarconfig==PLANARCONFIG_CONTIG)&& (td->td_photometric == PHOTOMETRIC_YCBCR)&& @@ -91,12 +91,12 @@ TIFFVStripSize64(TIFF* tif, uint32 nrows) * horizontal/vertical subsampling area include * YCbCr data for the extended image. */ - uint16 ycbcrsubsampling[2]; - uint16 samplingblock_samples; - uint32 samplingblocks_hor; - uint32 samplingblocks_ver; - uint64 samplingrow_samples; - uint64 samplingrow_size; + uint16_t ycbcrsubsampling[2]; + uint16_t samplingblock_samples; + uint32_t samplingblocks_hor; + uint32_t samplingblocks_ver; + uint64_t samplingrow_samples; + uint64_t samplingrow_size; if(td->td_samplesperpixel!=3) { TIFFErrorExt(tif->tif_clientdata,module, @@ -125,10 +125,10 @@ TIFFVStripSize64(TIFF* tif, uint32 nrows) return(_TIFFMultiply64(tif,nrows,TIFFScanlineSize64(tif),module)); } tmsize_t -TIFFVStripSize(TIFF* tif, uint32 nrows) +TIFFVStripSize(TIFF* tif, uint32_t nrows) { static const char module[] = "TIFFVStripSize"; - uint64 m; + uint64_t m; m=TIFFVStripSize64(tif,nrows); return _TIFFCastUInt64ToSSize(tif, m, module); } @@ -136,43 +136,36 @@ TIFFVStripSize(TIFF* tif, uint32 nrows) /* * Compute the # bytes in a raw strip. */ -uint64 -TIFFRawStripSize64(TIFF* tif, uint32 strip) +uint64_t +TIFFRawStripSize64(TIFF* tif, uint32_t strip) { static const char module[] = "TIFFRawStripSize64"; - uint64 bytecount = TIFFGetStrileByteCount(tif, strip); + uint64_t bytecount = TIFFGetStrileByteCount(tif, strip); if (bytecount == 0) { -#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__)) TIFFErrorExt(tif->tif_clientdata, module, - "%I64u: Invalid strip byte count, strip %lu", - (unsigned __int64) bytecount, + "%"PRIu64": Invalid strip byte count, strip %lu", + (uint64_t) bytecount, (unsigned long) strip); -#else - TIFFErrorExt(tif->tif_clientdata, module, - "%llu: Invalid strip byte count, strip %lu", - (unsigned long long) bytecount, - (unsigned long) strip); -#endif - bytecount = (uint64) -1; + bytecount = (uint64_t) -1; } return bytecount; } tmsize_t -TIFFRawStripSize(TIFF* tif, uint32 strip) +TIFFRawStripSize(TIFF* tif, uint32_t strip) { static const char module[] = "TIFFRawStripSize"; - uint64 m; + uint64_t m; tmsize_t n; m=TIFFRawStripSize64(tif,strip); - if (m==(uint64)(-1)) + if (m==(uint64_t)(-1)) n=(tmsize_t)(-1); else { n=(tmsize_t)m; - if ((uint64)n!=m) + if ((uint64_t)n != m) { TIFFErrorExt(tif->tif_clientdata,module,"Integer overflow"); n=0; @@ -189,11 +182,11 @@ TIFFRawStripSize(TIFF* tif, uint32 strip) * truncated to reflect the actual space required * to hold the strip. */ -uint64 +uint64_t TIFFStripSize64(TIFF* tif) { TIFFDirectory* td = &tif->tif_dir; - uint32 rps = td->td_rowsperstrip; + uint32_t rps = td->td_rowsperstrip; if (rps > td->td_imagelength) rps = td->td_imagelength; return (TIFFVStripSize64(tif, rps)); @@ -202,7 +195,7 @@ tmsize_t TIFFStripSize(TIFF* tif) { static const char module[] = "TIFFStripSize"; - uint64 m; + uint64_t m; m=TIFFStripSize64(tif); return _TIFFCastUInt64ToSSize(tif, m, module); } @@ -213,32 +206,32 @@ TIFFStripSize(TIFF* tif) * request is <1 then we choose a strip size according * to certain heuristics. */ -uint32 -TIFFDefaultStripSize(TIFF* tif, uint32 request) +uint32_t +TIFFDefaultStripSize(TIFF* tif, uint32_t request) { return (*tif->tif_defstripsize)(tif, request); } -uint32 -_TIFFDefaultStripSize(TIFF* tif, uint32 s) +uint32_t +_TIFFDefaultStripSize(TIFF* tif, uint32_t s) { - if ((int32) s < 1) { + if ((int32_t) s < 1) { /* * If RowsPerStrip is unspecified, try to break the * image up into strips that are approximately * STRIP_SIZE_DEFAULT bytes long. */ - uint64 scanlinesize; - uint64 rows; + uint64_t scanlinesize; + uint64_t rows; scanlinesize=TIFFScanlineSize64(tif); if (scanlinesize==0) scanlinesize=1; - rows=(uint64)STRIP_SIZE_DEFAULT/scanlinesize; + rows= (uint64_t)STRIP_SIZE_DEFAULT / scanlinesize; if (rows==0) rows=1; else if (rows>0xFFFFFFFF) rows=0xFFFFFFFF; - s=(uint32)rows; + s=(uint32_t)rows; } return (s); } @@ -253,23 +246,23 @@ _TIFFDefaultStripSize(TIFF* tif, uint32 s) * subsampling lines divided by vertical subsampling. It should thus make * sense when multiplied by a multiple of vertical subsampling. */ -uint64 +uint64_t TIFFScanlineSize64(TIFF* tif) { static const char module[] = "TIFFScanlineSize64"; TIFFDirectory *td = &tif->tif_dir; - uint64 scanline_size; + uint64_t scanline_size; if (td->td_planarconfig==PLANARCONFIG_CONTIG) { if ((td->td_photometric==PHOTOMETRIC_YCBCR)&& (td->td_samplesperpixel==3)&& (!isUpSampled(tif))) { - uint16 ycbcrsubsampling[2]; - uint16 samplingblock_samples; - uint32 samplingblocks_hor; - uint64 samplingrow_samples; - uint64 samplingrow_size; + uint16_t ycbcrsubsampling[2]; + uint16_t samplingblock_samples; + uint32_t samplingblocks_hor; + uint64_t samplingrow_samples; + uint64_t samplingrow_size; if(td->td_samplesperpixel!=3) { TIFFErrorExt(tif->tif_clientdata,module, @@ -294,7 +287,7 @@ TIFFScanlineSize64(TIFF* tif) } else { - uint64 scanline_samples; + uint64_t scanline_samples; scanline_samples=_TIFFMultiply64(tif,td->td_imagewidth,td->td_samplesperpixel,module); scanline_size=TIFFhowmany_64(_TIFFMultiply64(tif,scanline_samples,td->td_bitspersample,module),8); } @@ -314,7 +307,7 @@ tmsize_t TIFFScanlineSize(TIFF* tif) { static const char module[] = "TIFFScanlineSize"; - uint64 m; + uint64_t m; m=TIFFScanlineSize64(tif); return _TIFFCastUInt64ToSSize(tif, m, module); } @@ -325,12 +318,12 @@ TIFFScanlineSize(TIFF* tif) * I/O size returned by TIFFScanlineSize which may be less * if data is store as separate planes). */ -uint64 +uint64_t TIFFRasterScanlineSize64(TIFF* tif) { static const char module[] = "TIFFRasterScanlineSize64"; TIFFDirectory *td = &tif->tif_dir; - uint64 scanline; + uint64_t scanline; scanline = _TIFFMultiply64(tif, td->td_bitspersample, td->td_imagewidth, module); if (td->td_planarconfig == PLANARCONFIG_CONTIG) { @@ -344,7 +337,7 @@ tmsize_t TIFFRasterScanlineSize(TIFF* tif) { static const char module[] = "TIFFRasterScanlineSize"; - uint64 m; + uint64_t m; m=TIFFRasterScanlineSize64(tif); return _TIFFCastUInt64ToSSize(tif, m, module); } diff --git a/tiff/libtiff/tif_swab.c b/tiff/libtiff/tif_swab.c index b174ba69..3d4bb6ca 100644 --- a/tiff/libtiff/tif_swab.c +++ b/tiff/libtiff/tif_swab.c @@ -31,22 +31,22 @@ #if defined(DISABLE_CHECK_TIFFSWABMACROS) || !defined(TIFFSwabShort) void -TIFFSwabShort(uint16* wp) +TIFFSwabShort(uint16_t* wp) { register unsigned char* cp = (unsigned char*) wp; unsigned char t; - assert(sizeof(uint16)==2); + assert(sizeof(uint16_t) == 2); t = cp[1]; cp[1] = cp[0]; cp[0] = t; } #endif #if defined(DISABLE_CHECK_TIFFSWABMACROS) || !defined(TIFFSwabLong) void -TIFFSwabLong(uint32* lp) +TIFFSwabLong(uint32_t* lp) { register unsigned char* cp = (unsigned char*) lp; unsigned char t; - assert(sizeof(uint32)==4); + assert(sizeof(uint32_t) == 4); t = cp[3]; cp[3] = cp[0]; cp[0] = t; t = cp[2]; cp[2] = cp[1]; cp[1] = t; } @@ -54,11 +54,11 @@ TIFFSwabLong(uint32* lp) #if defined(DISABLE_CHECK_TIFFSWABMACROS) || !defined(TIFFSwabLong8) void -TIFFSwabLong8(uint64* lp) +TIFFSwabLong8(uint64_t* lp) { register unsigned char* cp = (unsigned char*) lp; unsigned char t; - assert(sizeof(uint64)==8); + assert(sizeof(uint64_t) == 8); t = cp[7]; cp[7] = cp[0]; cp[0] = t; t = cp[6]; cp[6] = cp[1]; cp[1] = t; t = cp[5]; cp[5] = cp[2]; cp[2] = t; @@ -68,11 +68,11 @@ TIFFSwabLong8(uint64* lp) #if defined(DISABLE_CHECK_TIFFSWABMACROS) || !defined(TIFFSwabArrayOfShort) void -TIFFSwabArrayOfShort(register uint16* wp, tmsize_t n) +TIFFSwabArrayOfShort(register uint16_t* wp, tmsize_t n) { register unsigned char* cp; register unsigned char t; - assert(sizeof(uint16)==2); + assert(sizeof(uint16_t) == 2); /* XXX unroll loop some */ while (n-- > 0) { cp = (unsigned char*) wp; @@ -84,7 +84,7 @@ TIFFSwabArrayOfShort(register uint16* wp, tmsize_t n) #if defined(DISABLE_CHECK_TIFFSWABMACROS) || !defined(TIFFSwabArrayOfTriples) void -TIFFSwabArrayOfTriples(register uint8* tp, tmsize_t n) +TIFFSwabArrayOfTriples(register uint8_t* tp, tmsize_t n) { unsigned char* cp; unsigned char t; @@ -100,11 +100,11 @@ TIFFSwabArrayOfTriples(register uint8* tp, tmsize_t n) #if defined(DISABLE_CHECK_TIFFSWABMACROS) || !defined(TIFFSwabArrayOfLong) void -TIFFSwabArrayOfLong(register uint32* lp, tmsize_t n) +TIFFSwabArrayOfLong(register uint32_t* lp, tmsize_t n) { register unsigned char *cp; register unsigned char t; - assert(sizeof(uint32)==4); + assert(sizeof(uint32_t) == 4); /* XXX unroll loop some */ while (n-- > 0) { cp = (unsigned char *)lp; @@ -117,11 +117,11 @@ TIFFSwabArrayOfLong(register uint32* lp, tmsize_t n) #if defined(DISABLE_CHECK_TIFFSWABMACROS) || !defined(TIFFSwabArrayOfLong8) void -TIFFSwabArrayOfLong8(register uint64* lp, tmsize_t n) +TIFFSwabArrayOfLong8(register uint64_t* lp, tmsize_t n) { register unsigned char *cp; register unsigned char t; - assert(sizeof(uint64)==8); + assert(sizeof(uint64_t) == 8); /* XXX unroll loop some */ while (n-- > 0) { cp = (unsigned char *)lp; @@ -281,7 +281,7 @@ TIFFGetBitRevTable(int reversed) } void -TIFFReverseBits(uint8* cp, tmsize_t n) +TIFFReverseBits(uint8_t* cp, tmsize_t n) { for (; n > 8; n -= 8) { cp[0] = TIFFBitRevTable[cp[0]]; diff --git a/tiff/libtiff/tif_thunder.c b/tiff/libtiff/tif_thunder.c index b56e3c35..3e703d8b 100644 --- a/tiff/libtiff/tif_thunder.c +++ b/tiff/libtiff/tif_thunder.c @@ -61,7 +61,7 @@ static const int threebitdeltas[8] = { 0, 1, 2, 3, 0, -3, -2, -1 }; if (npixels++ & 1) \ *op++ |= lastpixel; \ else \ - op[0] = (uint8) (lastpixel << 4); \ + op[0] = (uint8_t) (lastpixel << 4); \ } \ } @@ -83,7 +83,7 @@ ThunderSetupDecode(TIFF* tif) } static int -ThunderDecode(TIFF* tif, uint8* op, tmsize_t maxpixels) +ThunderDecode(TIFF* tif, uint8_t* op, tmsize_t maxpixels) { static const char module[] = "ThunderDecode"; register unsigned char *bp; @@ -112,10 +112,10 @@ ThunderDecode(TIFF* tif, uint8* op, tmsize_t maxpixels) } else lastpixel |= lastpixel << 4; npixels += n; - if (npixels > maxpixels) - n -= npixels - maxpixels; - for (; n > 0; n -= 2) - *op++ = (uint8) lastpixel; + if (npixels < maxpixels) { + for (; n > 0; n -= 2) + *op++ = (uint8_t) lastpixel; + } if (n == -1) *--op &= 0xf0; lastpixel &= 0xf; @@ -139,24 +139,15 @@ ThunderDecode(TIFF* tif, uint8* op, tmsize_t maxpixels) break; } } - tif->tif_rawcp = (uint8*) bp; + tif->tif_rawcp = (uint8_t*) bp; tif->tif_rawcc = cc; if (npixels != maxpixels) { -#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__)) TIFFErrorExt(tif->tif_clientdata, module, - "%s data at scanline %lu (%I64u != %I64u)", + "%s data at scanline %lu (%"PRIu64" != %"PRIu64")", npixels < maxpixels ? "Not enough" : "Too much", (unsigned long) tif->tif_row, - (unsigned __int64) npixels, - (unsigned __int64) maxpixels); -#else - TIFFErrorExt(tif->tif_clientdata, module, - "%s data at scanline %lu (%llu != %llu)", - npixels < maxpixels ? "Not enough" : "Too much", - (unsigned long) tif->tif_row, - (unsigned long long) npixels, - (unsigned long long) maxpixels); -#endif + (uint64_t) npixels, + (uint64_t) maxpixels); return (0); } @@ -164,10 +155,10 @@ ThunderDecode(TIFF* tif, uint8* op, tmsize_t maxpixels) } static int -ThunderDecodeRow(TIFF* tif, uint8* buf, tmsize_t occ, uint16 s) +ThunderDecodeRow(TIFF* tif, uint8_t* buf, tmsize_t occ, uint16_t s) { static const char module[] = "ThunderDecodeRow"; - uint8* row = buf; + uint8_t* row = buf; (void) s; if (occ % tif->tif_scanlinesize) diff --git a/tiff/libtiff/tif_tile.c b/tiff/libtiff/tif_tile.c index 661cc771..058be9f7 100644 --- a/tiff/libtiff/tif_tile.c +++ b/tiff/libtiff/tif_tile.c @@ -32,27 +32,27 @@ /* * Compute which tile an (x,y,z,s) value is in. */ -uint32 -TIFFComputeTile(TIFF* tif, uint32 x, uint32 y, uint32 z, uint16 s) +uint32_t +TIFFComputeTile(TIFF* tif, uint32_t x, uint32_t y, uint32_t z, uint16_t s) { TIFFDirectory *td = &tif->tif_dir; - uint32 dx = td->td_tilewidth; - uint32 dy = td->td_tilelength; - uint32 dz = td->td_tiledepth; - uint32 tile = 1; + uint32_t dx = td->td_tilewidth; + uint32_t dy = td->td_tilelength; + uint32_t dz = td->td_tiledepth; + uint32_t tile = 1; if (td->td_imagedepth == 1) z = 0; - if (dx == (uint32) -1) + if (dx == (uint32_t) -1) dx = td->td_imagewidth; - if (dy == (uint32) -1) + if (dy == (uint32_t) -1) dy = td->td_imagelength; - if (dz == (uint32) -1) + if (dz == (uint32_t) -1) dz = td->td_imagedepth; if (dx != 0 && dy != 0 && dz != 0) { - uint32 xpt = TIFFhowmany_32(td->td_imagewidth, dx); - uint32 ypt = TIFFhowmany_32(td->td_imagelength, dy); - uint32 zpt = TIFFhowmany_32(td->td_imagedepth, dz); + uint32_t xpt = TIFFhowmany_32(td->td_imagewidth, dx); + uint32_t ypt = TIFFhowmany_32(td->td_imagelength, dy); + uint32_t zpt = TIFFhowmany_32(td->td_imagedepth, dz); if (td->td_planarconfig == PLANARCONFIG_SEPARATE) tile = (xpt*ypt*zpt)*s + @@ -70,7 +70,7 @@ TIFFComputeTile(TIFF* tif, uint32 x, uint32 y, uint32 z, uint16 s) * against the image bounds. */ int -TIFFCheckTile(TIFF* tif, uint32 x, uint32 y, uint32 z, uint16 s) +TIFFCheckTile(TIFF* tif, uint32_t x, uint32_t y, uint32_t z, uint16_t s) { TIFFDirectory *td = &tif->tif_dir; @@ -109,20 +109,20 @@ TIFFCheckTile(TIFF* tif, uint32 x, uint32 y, uint32 z, uint16 s) /* * Compute how many tiles are in an image. */ -uint32 +uint32_t TIFFNumberOfTiles(TIFF* tif) { TIFFDirectory *td = &tif->tif_dir; - uint32 dx = td->td_tilewidth; - uint32 dy = td->td_tilelength; - uint32 dz = td->td_tiledepth; - uint32 ntiles; + uint32_t dx = td->td_tilewidth; + uint32_t dy = td->td_tilelength; + uint32_t dz = td->td_tiledepth; + uint32_t ntiles; - if (dx == (uint32) -1) + if (dx == (uint32_t) -1) dx = td->td_imagewidth; - if (dy == (uint32) -1) + if (dy == (uint32_t) -1) dy = td->td_imagelength; - if (dz == (uint32) -1) + if (dz == (uint32_t) -1) dz = td->td_imagedepth; ntiles = (dx == 0 || dy == 0 || dz == 0) ? 0 : _TIFFMultiply32(tif, _TIFFMultiply32(tif, TIFFhowmany_32(td->td_imagewidth, dx), @@ -138,13 +138,13 @@ TIFFNumberOfTiles(TIFF* tif) /* * Compute the # bytes in each row of a tile. */ -uint64 +uint64_t TIFFTileRowSize64(TIFF* tif) { static const char module[] = "TIFFTileRowSize64"; TIFFDirectory *td = &tif->tif_dir; - uint64 rowsize; - uint64 tilerowsize; + uint64_t rowsize; + uint64_t tilerowsize; if (td->td_tilelength == 0) { @@ -180,7 +180,7 @@ tmsize_t TIFFTileRowSize(TIFF* tif) { static const char module[] = "TIFFTileRowSize"; - uint64 m; + uint64_t m; m=TIFFTileRowSize64(tif); return _TIFFCastUInt64ToSSize(tif, m, module); } @@ -188,8 +188,8 @@ TIFFTileRowSize(TIFF* tif) /* * Compute the # bytes in a variable length, row-aligned tile. */ -uint64 -TIFFVTileSize64(TIFF* tif, uint32 nrows) +uint64_t +TIFFVTileSize64(TIFF* tif, uint32_t nrows) { static const char module[] = "TIFFVTileSize64"; TIFFDirectory *td = &tif->tif_dir; @@ -209,12 +209,12 @@ TIFFVTileSize64(TIFF* tif, uint32 nrows) * horizontal/vertical subsampling area include * YCbCr data for the extended image. */ - uint16 ycbcrsubsampling[2]; - uint16 samplingblock_samples; - uint32 samplingblocks_hor; - uint32 samplingblocks_ver; - uint64 samplingrow_samples; - uint64 samplingrow_size; + uint16_t ycbcrsubsampling[2]; + uint16_t samplingblock_samples; + uint32_t samplingblocks_hor; + uint32_t samplingblocks_ver; + uint64_t samplingrow_samples; + uint64_t samplingrow_size; TIFFGetFieldDefaulted(tif,TIFFTAG_YCBCRSUBSAMPLING,ycbcrsubsampling+0, ycbcrsubsampling+1); if ((ycbcrsubsampling[0] != 1 && ycbcrsubsampling[0] != 2 && ycbcrsubsampling[0] != 4) @@ -237,10 +237,10 @@ TIFFVTileSize64(TIFF* tif, uint32 nrows) return(_TIFFMultiply64(tif,nrows,TIFFTileRowSize64(tif),module)); } tmsize_t -TIFFVTileSize(TIFF* tif, uint32 nrows) +TIFFVTileSize(TIFF* tif, uint32_t nrows) { static const char module[] = "TIFFVTileSize"; - uint64 m; + uint64_t m; m=TIFFVTileSize64(tif,nrows); return _TIFFCastUInt64ToSSize(tif, m, module); } @@ -248,7 +248,7 @@ TIFFVTileSize(TIFF* tif, uint32 nrows) /* * Compute the # bytes in a row-aligned tile. */ -uint64 +uint64_t TIFFTileSize64(TIFF* tif) { return (TIFFVTileSize64(tif, tif->tif_dir.td_tilelength)); @@ -257,7 +257,7 @@ tmsize_t TIFFTileSize(TIFF* tif) { static const char module[] = "TIFFTileSize"; - uint64 m; + uint64_t m; m=TIFFTileSize64(tif); return _TIFFCastUInt64ToSSize(tif, m, module); } @@ -269,18 +269,18 @@ TIFFTileSize(TIFF* tif) * to certain heuristics. */ void -TIFFDefaultTileSize(TIFF* tif, uint32* tw, uint32* th) +TIFFDefaultTileSize(TIFF* tif, uint32_t* tw, uint32_t* th) { (*tif->tif_deftilesize)(tif, tw, th); } void -_TIFFDefaultTileSize(TIFF* tif, uint32* tw, uint32* th) +_TIFFDefaultTileSize(TIFF* tif, uint32_t* tw, uint32_t* th) { (void) tif; - if (*(int32*) tw < 1) + if (*(int32_t*) tw < 1) *tw = 256; - if (*(int32*) th < 1) + if (*(int32_t*) th < 1) *th = 256; /* roundup to a multiple of 16 per the spec */ if (*tw & 0xf) diff --git a/tiff/libtiff/tif_unix.c b/tiff/libtiff/tif_unix.c index bea1ef78..cb543542 100644 --- a/tiff/libtiff/tif_unix.c +++ b/tiff/libtiff/tif_unix.c @@ -120,18 +120,18 @@ _tiffWriteProc(thandle_t fd, void* buf, tmsize_t size) /* return ((tmsize_t) write(fdh.fd, buf, bytes_total)); */ } -static uint64 -_tiffSeekProc(thandle_t fd, uint64 off, int whence) +static uint64_t +_tiffSeekProc(thandle_t fd, uint64_t off, int whence) { fd_as_handle_union_t fdh; _TIFF_off_t off_io = (_TIFF_off_t) off; - if ((uint64) off_io != off) + if ((uint64_t) off_io != off) { errno=EINVAL; - return (uint64) -1; /* this is really gross */ + return (uint64_t) -1; /* this is really gross */ } fdh.h = fd; - return((uint64)_TIFF_lseek_f(fdh.fd,off_io,whence)); + return((uint64_t)_TIFF_lseek_f(fdh.fd, off_io, whence)); } static int @@ -142,7 +142,7 @@ _tiffCloseProc(thandle_t fd) return(close(fdh.fd)); } -static uint64 +static uint64_t _tiffSizeProc(thandle_t fd) { _TIFF_stat_s sb; @@ -151,7 +151,7 @@ _tiffSizeProc(thandle_t fd) if (_TIFF_fstat_f(fdh.fd,&sb)<0) return(0); else - return((uint64)sb.st_size); + return((uint64_t)sb.st_size); } #ifdef HAVE_MMAP @@ -160,9 +160,9 @@ _tiffSizeProc(thandle_t fd) static int _tiffMapProc(thandle_t fd, void** pbase, toff_t* psize) { - uint64 size64 = _tiffSizeProc(fd); + uint64_t size64 = _tiffSizeProc(fd); tmsize_t sizem = (tmsize_t)size64; - if (size64 && (uint64)sizem==size64) { + if (size64 && (uint64_t)sizem == size64) { fd_as_handle_union_t fdh; fdh.h = fd; *pbase = (void*) diff --git a/tiff/libtiff/tif_webp.c b/tiff/libtiff/tif_webp.c index a00478f6..d5b99d35 100644 --- a/tiff/libtiff/tif_webp.c +++ b/tiff/libtiff/tif_webp.c @@ -43,13 +43,13 @@ * file using WEBP compression/decompression. */ typedef struct { - uint16 nSamples; /* number of samples per pixel */ + uint16_t nSamples; /* number of samples per pixel */ int lossless; /* lossy/lossless compression */ int quality_level; /* compression level */ WebPPicture sPicture; /* WebP Picture */ WebPConfig sEncoderConfig; /* WebP encoder config */ - uint8* pBuffer; /* buffer to hold raw data on encoding */ + uint8_t* pBuffer; /* buffer to hold raw data on encoding */ unsigned int buffer_offset; /* current offset into the buffer */ unsigned int buffer_size; @@ -67,8 +67,8 @@ typedef struct { #define DecoderState(tif) LState(tif) #define EncoderState(tif) LState(tif) -static int TWebPEncode(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s); -static int TWebPDecode(TIFF* tif, uint8* op, tmsize_t occ, uint16 s); +static int TWebPEncode(TIFF* tif, uint8_t* bp, tmsize_t cc, uint16_t s); +static int TWebPDecode(TIFF* tif, uint8_t* op, tmsize_t occ, uint16_t s); static int TWebPDatasetWriter(const uint8_t* data, size_t data_size, @@ -79,7 +79,7 @@ int TWebPDatasetWriter(const uint8_t* data, size_t data_size, if ( (tif->tif_rawcc + (tmsize_t)data_size) > tif->tif_rawdatasize ) { TIFFErrorExt(tif->tif_clientdata, module, - "Buffer too small by " TIFF_SIZE_FORMAT " bytes.", + "Buffer too small by %"TIFF_SIZE_FORMAT" bytes.", (size_t) (tif->tif_rawcc + data_size - tif->tif_rawdatasize)); return 0; } else { @@ -94,7 +94,7 @@ int TWebPDatasetWriter(const uint8_t* data, size_t data_size, * Encode a chunk of pixels. */ static int -TWebPEncode(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) +TWebPEncode(TIFF* tif, uint8_t* bp, tmsize_t cc, uint16_t s) { static const char module[] = "TWebPEncode"; WebPState *sp = EncoderState(tif); @@ -103,8 +103,8 @@ TWebPEncode(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) assert(sp != NULL); assert(sp->state == LSTATE_INIT_ENCODE); - if( (uint64)sp->buffer_offset + - (uint64)cc > sp->buffer_size ) + if((uint64_t)sp->buffer_offset + + (uint64_t)cc > sp->buffer_size ) { TIFFErrorExt(tif->tif_clientdata, module, "Too many bytes to be written"); @@ -120,7 +120,7 @@ TWebPEncode(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) } static int -TWebPDecode(TIFF* tif, uint8* op, tmsize_t occ, uint16 s) +TWebPDecode(TIFF* tif, uint8_t* op, tmsize_t occ, uint16_t s) { static const char module[] = "WebPDecode"; VP8StatusCode status = VP8_STATUS_OK; @@ -159,7 +159,7 @@ TWebPDecode(TIFF* tif, uint8* op, tmsize_t occ, uint16 s) buf = WebPIDecGetRGB(sp->psDecoder, ¤t_y, NULL, NULL, &stride); if ((buf != NULL) && - (occ <= stride * (current_y - sp->last_y))) { + (occ <= (tmsize_t)stride * (current_y - sp->last_y))) { memcpy(op, buf + (sp->last_y * stride), occ); @@ -196,8 +196,8 @@ static int TWebPSetupDecode(TIFF* tif) { static const char module[] = "WebPSetupDecode"; - uint16 nBitsPerSample = tif->tif_dir.td_bitspersample; - uint16 sampleFormat = tif->tif_dir.td_sampleformat; + uint16_t nBitsPerSample = tif->tif_dir.td_bitspersample; + uint16_t sampleFormat = tif->tif_dir.td_sampleformat; WebPState* sp = DecoderState(tif); assert(sp != NULL); @@ -248,10 +248,10 @@ TWebPSetupDecode(TIFF* tif) * Setup state for decoding a strip. */ static int -TWebPPreDecode(TIFF* tif, uint16 s) +TWebPPreDecode(TIFF* tif, uint16_t s) { static const char module[] = "TWebPPreDecode"; - uint32 segment_width, segment_height; + uint32_t segment_width, segment_height; WebPState* sp = DecoderState(tif); TIFFDirectory* td = &tif->tif_dir; (void) s; @@ -313,8 +313,8 @@ static int TWebPSetupEncode(TIFF* tif) { static const char module[] = "WebPSetupEncode"; - uint16 nBitsPerSample = tif->tif_dir.td_bitspersample; - uint16 sampleFormat = tif->tif_dir.td_sampleformat; + uint16_t nBitsPerSample = tif->tif_dir.td_bitspersample; + uint16_t sampleFormat = tif->tif_dir.td_sampleformat; WebPState* sp = EncoderState(tif); assert(sp != NULL); @@ -390,10 +390,10 @@ TWebPSetupEncode(TIFF* tif) * Reset encoding state at the start of a strip. */ static int -TWebPPreEncode(TIFF* tif, uint16 s) +TWebPPreEncode(TIFF* tif, uint16_t s) { static const char module[] = "TWebPPreEncode"; - uint32 segment_width, segment_height; + uint32_t segment_width, segment_height; WebPState *sp = EncoderState(tif); TIFFDirectory* td = &tif->tif_dir; @@ -567,7 +567,7 @@ TWebPCleanup(TIFF* tif) } static int -TWebPVSetField(TIFF* tif, uint32 tag, va_list ap) +TWebPVSetField(TIFF* tif, uint32_t tag, va_list ap) { static const char module[] = "WebPVSetField"; WebPState* sp = LState(tif); @@ -601,7 +601,7 @@ TWebPVSetField(TIFF* tif, uint32 tag, va_list ap) } static int -TWebPVGetField(TIFF* tif, uint32 tag, va_list ap) +TWebPVGetField(TIFF* tif, uint32_t tag, va_list ap) { WebPState* sp = LState(tif); @@ -649,7 +649,7 @@ TIFFInitWebP(TIFF* tif, int scheme) /* * Allocate state block so tag methods have storage to record values. */ - tif->tif_data = (uint8*) _TIFFmalloc(sizeof(WebPState)); + tif->tif_data = (uint8_t*) _TIFFmalloc(sizeof(WebPState)); if (tif->tif_data == NULL) goto bad; sp = LState(tif); diff --git a/tiff/libtiff/tif_win32.c b/tiff/libtiff/tif_win32.c index 89645693..c6ca1519 100644 --- a/tiff/libtiff/tif_win32.c +++ b/tiff/libtiff/tif_win32.c @@ -65,18 +65,18 @@ _tiffReadProc(thandle_t fd, void* buf, tmsize_t size) /* tmsize_t is 64bit on 64bit systems, but the WinAPI ReadFile takes * 32bit sizes, so we loop through the data in suitable 32bit sized * chunks */ - uint8* ma; - uint64 mb; + uint8_t* ma; + uint64_t mb; DWORD n; DWORD o; tmsize_t p; - ma=(uint8*)buf; + ma=(uint8_t*)buf; mb=size; p=0; while (mb>0) { n=0x80000000UL; - if ((uint64)n>mb) + if ((uint64_t)n>mb) n=(DWORD)mb; if (!ReadFile(fd,(LPVOID)ma,n,&o,NULL)) return(0); @@ -95,18 +95,18 @@ _tiffWriteProc(thandle_t fd, void* buf, tmsize_t size) /* tmsize_t is 64bit on 64bit systems, but the WinAPI WriteFile takes * 32bit sizes, so we loop through the data in suitable 32bit sized * chunks */ - uint8* ma; - uint64 mb; + uint8_t* ma; + uint64_t mb; DWORD n; DWORD o; tmsize_t p; - ma=(uint8*)buf; + ma=(uint8_t*)buf; mb=size; p=0; while (mb>0) { n=0x80000000UL; - if ((uint64)n>mb) + if ((uint64_t)n>mb) n=(DWORD)mb; if (!WriteFile(fd,(LPVOID)ma,n,&o,NULL)) return(0); @@ -119,8 +119,8 @@ _tiffWriteProc(thandle_t fd, void* buf, tmsize_t size) return(p); } -static uint64 -_tiffSeekProc(thandle_t fd, uint64 off, int whence) +static uint64_t +_tiffSeekProc(thandle_t fd, uint64_t off, int whence) { LARGE_INTEGER offli; DWORD dwMoveMethod; @@ -152,7 +152,7 @@ _tiffCloseProc(thandle_t fd) return (CloseHandle(fd) ? 0 : -1); } -static uint64 +static uint64_t _tiffSizeProc(thandle_t fd) { LARGE_INTEGER m; @@ -185,13 +185,13 @@ _tiffDummyMapProc(thandle_t fd, void** pbase, toff_t* psize) static int _tiffMapProc(thandle_t fd, void** pbase, toff_t* psize) { - uint64 size; + uint64_t size; tmsize_t sizem; HANDLE hMapFile; size = _tiffSizeProc(fd); sizem = (tmsize_t)size; - if (!size || (uint64)sizem!=size) + if (!size || (uint64_t)sizem!=size) return (0); /* By passing in 0 for the maximum file size, it specifies that we @@ -404,10 +404,6 @@ _TIFFmemcmp(const void* p1, const void* p2, tmsize_t c) #ifndef _WIN32_WCE -#if (_MSC_VER < 1500) -# define vsnprintf _vsnprintf -#endif - static void Win32WarningHandler(const char* module, const char* fmt, va_list ap) { diff --git a/tiff/libtiff/tif_write.c b/tiff/libtiff/tif_write.c index 3af69ab4..b5ef21d0 100644 --- a/tiff/libtiff/tif_write.c +++ b/tiff/libtiff/tif_write.c @@ -40,16 +40,16 @@ ((((tif)->tif_flags & TIFF_BUFFERSETUP) && tif->tif_rawdata) || \ TIFFWriteBufferSetup((tif), NULL, (tmsize_t) -1)) -static int TIFFGrowStrips(TIFF* tif, uint32 delta, const char* module); -static int TIFFAppendToStrip(TIFF* tif, uint32 strip, uint8* data, tmsize_t cc); +static int TIFFGrowStrips(TIFF* tif, uint32_t delta, const char* module); +static int TIFFAppendToStrip(TIFF* tif, uint32_t strip, uint8_t* data, tmsize_t cc); int -TIFFWriteScanline(TIFF* tif, void* buf, uint32 row, uint16 sample) +TIFFWriteScanline(TIFF* tif, void* buf, uint32_t row, uint16_t sample) { static const char module[] = "TIFFWriteScanline"; register TIFFDirectory *td; int status, imagegrew = 0; - uint32 strip; + uint32_t strip; if (!WRITECHECKSTRIPS(tif, module)) return (-1); @@ -166,9 +166,9 @@ TIFFWriteScanline(TIFF* tif, void* buf, uint32 row, uint16 sample) } /* swab if needed - note that source buffer will be altered */ - tif->tif_postdecode( tif, (uint8*) buf, tif->tif_scanlinesize ); + tif->tif_postdecode(tif, (uint8_t*) buf, tif->tif_scanlinesize ); - status = (*tif->tif_encoderow)(tif, (uint8*) buf, + status = (*tif->tif_encoderow)(tif, (uint8_t*) buf, tif->tif_scanlinesize, sample); /* we are now poised at the beginning of the next row */ @@ -180,14 +180,14 @@ TIFFWriteScanline(TIFF* tif, void* buf, uint32 row, uint16 sample) /* more bytes available in the output buffer than the previous byte count, */ /* so that TIFFAppendToStrip() will detect the overflow when it is called the first */ /* time if the new compressed tile is bigger than the older one. (GDAL #4771) */ -static int _TIFFReserveLargeEnoughWriteBuffer(TIFF* tif, uint32 strip_or_tile) +static int _TIFFReserveLargeEnoughWriteBuffer(TIFF* tif, uint32_t strip_or_tile) { TIFFDirectory *td = &tif->tif_dir; if( td->td_stripbytecount_p[strip_or_tile] > 0 ) { /* The +1 is to ensure at least one extra bytes */ /* The +4 is because the LZW encoder flushes 4 bytes before the limit */ - uint64 safe_buffer_size = (uint64)(td->td_stripbytecount_p[strip_or_tile] + 1 + 4); + uint64_t safe_buffer_size = (uint64_t)(td->td_stripbytecount_p[strip_or_tile] + 1 + 4); if( tif->tif_rawdatasize <= (tmsize_t)safe_buffer_size ) { if( !(TIFFWriteBufferSetup(tif, NULL, @@ -209,11 +209,11 @@ static int _TIFFReserveLargeEnoughWriteBuffer(TIFF* tif, uint32 strip_or_tile) * NB: Image length must be setup before writing. */ tmsize_t -TIFFWriteEncodedStrip(TIFF* tif, uint32 strip, void* data, tmsize_t cc) +TIFFWriteEncodedStrip(TIFF* tif, uint32_t strip, void* data, tmsize_t cc) { static const char module[] = "TIFFWriteEncodedStrip"; TIFFDirectory *td = &tif->tif_dir; - uint16 sample; + uint16_t sample; if (!WRITECHECKSTRIPS(tif, module)) return ((tmsize_t) -1); @@ -273,26 +273,26 @@ TIFFWriteEncodedStrip(TIFF* tif, uint32 strip, void* data, tmsize_t cc) if( td->td_compression == COMPRESSION_NONE ) { /* swab if needed - note that source buffer will be altered */ - tif->tif_postdecode( tif, (uint8*) data, cc ); + tif->tif_postdecode(tif, (uint8_t*) data, cc ); if (!isFillOrder(tif, td->td_fillorder) && (tif->tif_flags & TIFF_NOBITREV) == 0) - TIFFReverseBits((uint8*) data, cc); + TIFFReverseBits((uint8_t*) data, cc); if (cc > 0 && - !TIFFAppendToStrip(tif, strip, (uint8*) data, cc)) + !TIFFAppendToStrip(tif, strip, (uint8_t*) data, cc)) return ((tmsize_t) -1); return (cc); } - sample = (uint16)(strip / td->td_stripsperimage); + sample = (uint16_t)(strip / td->td_stripsperimage); if (!(*tif->tif_preencode)(tif, sample)) return ((tmsize_t) -1); /* swab if needed - note that source buffer will be altered */ - tif->tif_postdecode( tif, (uint8*) data, cc ); + tif->tif_postdecode(tif, (uint8_t*) data, cc ); - if (!(*tif->tif_encodestrip)(tif, (uint8*) data, cc, sample)) + if (!(*tif->tif_encodestrip)(tif, (uint8_t*) data, cc, sample)) return ((tmsize_t) -1); if (!(*tif->tif_postencode)(tif)) return ((tmsize_t) -1); @@ -313,7 +313,7 @@ TIFFWriteEncodedStrip(TIFF* tif, uint32 strip, void* data, tmsize_t cc) * NB: Image length must be setup before writing. */ tmsize_t -TIFFWriteRawStrip(TIFF* tif, uint32 strip, void* data, tmsize_t cc) +TIFFWriteRawStrip(TIFF* tif, uint32_t strip, void* data, tmsize_t cc) { static const char module[] = "TIFFWriteRawStrip"; TIFFDirectory *td = &tif->tif_dir; @@ -352,7 +352,7 @@ TIFFWriteRawStrip(TIFF* tif, uint32 strip, void* data, tmsize_t cc) return ((tmsize_t) -1); } tif->tif_row = (strip % td->td_stripsperimage) * td->td_rowsperstrip; - return (TIFFAppendToStrip(tif, strip, (uint8*) data, cc) ? + return (TIFFAppendToStrip(tif, strip, (uint8_t*) data, cc) ? cc : (tmsize_t) -1); } @@ -361,7 +361,7 @@ TIFFWriteRawStrip(TIFF* tif, uint32 strip, void* data, tmsize_t cc) * tile is selected by the (x,y,z,s) coordinates. */ tmsize_t -TIFFWriteTile(TIFF* tif, void* buf, uint32 x, uint32 y, uint32 z, uint16 s) +TIFFWriteTile(TIFF* tif, void* buf, uint32_t x, uint32_t y, uint32_t z, uint16_t s) { if (!TIFFCheckTile(tif, x, y, z, s)) return ((tmsize_t)(-1)); @@ -388,12 +388,12 @@ TIFFWriteTile(TIFF* tif, void* buf, uint32 x, uint32 y, uint32 z, uint16 s) * the image on each write (as TIFFWriteScanline does). */ tmsize_t -TIFFWriteEncodedTile(TIFF* tif, uint32 tile, void* data, tmsize_t cc) +TIFFWriteEncodedTile(TIFF* tif, uint32_t tile, void* data, tmsize_t cc) { static const char module[] = "TIFFWriteEncodedTile"; TIFFDirectory *td; - uint16 sample; - uint32 howmany32; + uint16_t sample; + uint32_t howmany32; if (!WRITECHECKTILES(tif, module)) return ((tmsize_t)(-1)); @@ -457,31 +457,31 @@ TIFFWriteEncodedTile(TIFF* tif, uint32 tile, void* data, tmsize_t cc) if( td->td_compression == COMPRESSION_NONE ) { /* swab if needed - note that source buffer will be altered */ - tif->tif_postdecode( tif, (uint8*) data, cc ); + tif->tif_postdecode(tif, (uint8_t*) data, cc ); if (!isFillOrder(tif, td->td_fillorder) && (tif->tif_flags & TIFF_NOBITREV) == 0) - TIFFReverseBits((uint8*) data, cc); + TIFFReverseBits((uint8_t*) data, cc); if (cc > 0 && - !TIFFAppendToStrip(tif, tile, (uint8*) data, cc)) + !TIFFAppendToStrip(tif, tile, (uint8_t*) data, cc)) return ((tmsize_t) -1); return (cc); } - sample = (uint16)(tile/td->td_stripsperimage); + sample = (uint16_t)(tile / td->td_stripsperimage); if (!(*tif->tif_preencode)(tif, sample)) return ((tmsize_t)(-1)); /* swab if needed - note that source buffer will be altered */ - tif->tif_postdecode( tif, (uint8*) data, cc ); + tif->tif_postdecode(tif, (uint8_t*) data, cc ); - if (!(*tif->tif_encodetile)(tif, (uint8*) data, cc, sample)) + if (!(*tif->tif_encodetile)(tif, (uint8_t*) data, cc, sample)) return ((tmsize_t) -1); if (!(*tif->tif_postencode)(tif)) return ((tmsize_t)(-1)); if (!isFillOrder(tif, td->td_fillorder) && (tif->tif_flags & TIFF_NOBITREV) == 0) - TIFFReverseBits((uint8*)tif->tif_rawdata, tif->tif_rawcc); + TIFFReverseBits((uint8_t*)tif->tif_rawdata, tif->tif_rawcc); if (tif->tif_rawcc > 0 && !TIFFAppendToStrip(tif, tile, tif->tif_rawdata, tif->tif_rawcc)) return ((tmsize_t)(-1)); @@ -500,7 +500,7 @@ TIFFWriteEncodedTile(TIFF* tif, uint32 tile, void* data, tmsize_t cc) * the image on each write (as TIFFWriteScanline does). */ tmsize_t -TIFFWriteRawTile(TIFF* tif, uint32 tile, void* data, tmsize_t cc) +TIFFWriteRawTile(TIFF* tif, uint32_t tile, void* data, tmsize_t cc) { static const char module[] = "TIFFWriteRawTile"; @@ -512,7 +512,7 @@ TIFFWriteRawTile(TIFF* tif, uint32 tile, void* data, tmsize_t cc) (unsigned long) tif->tif_dir.td_nstrips); return ((tmsize_t)(-1)); } - return (TIFFAppendToStrip(tif, tile, (uint8*) data, cc) ? + return (TIFFAppendToStrip(tif, tile, (uint8_t*) data, cc) ? cc : (tmsize_t)(-1)); } @@ -542,11 +542,11 @@ TIFFSetupStrips(TIFF* tif) } if (td->td_planarconfig == PLANARCONFIG_SEPARATE) td->td_stripsperimage /= td->td_samplesperpixel; - td->td_stripoffset_p = (uint64 *) - _TIFFCheckMalloc(tif, td->td_nstrips, sizeof (uint64), + td->td_stripoffset_p = (uint64_t *) + _TIFFCheckMalloc(tif, td->td_nstrips, sizeof (uint64_t), "for \"StripOffsets\" array"); - td->td_stripbytecount_p = (uint64 *) - _TIFFCheckMalloc(tif, td->td_nstrips, sizeof (uint64), + td->td_stripbytecount_p = (uint64_t *) + _TIFFCheckMalloc(tif, td->td_nstrips, sizeof (uint64_t), "for \"StripByteCounts\" array"); if (td->td_stripoffset_p == NULL || td->td_stripbytecount_p == NULL) return (0); @@ -554,8 +554,8 @@ TIFFSetupStrips(TIFF* tif) * Place data at the end-of-file * (by setting offsets to zero). */ - _TIFFmemset(td->td_stripoffset_p, 0, td->td_nstrips*sizeof (uint64)); - _TIFFmemset(td->td_stripbytecount_p, 0, td->td_nstrips*sizeof (uint64)); + _TIFFmemset(td->td_stripoffset_p, 0, td->td_nstrips*sizeof (uint64_t)); + _TIFFmemset(td->td_stripbytecount_p, 0, td->td_nstrips*sizeof (uint64_t)); TIFFSetFieldBit(tif, FIELD_STRIPOFFSETS); TIFFSetFieldBit(tif, FIELD_STRIPBYTECOUNTS); return (1); @@ -688,7 +688,7 @@ TIFFWriteBufferSetup(TIFF* tif, void* bp, tmsize_t size) tif->tif_flags |= TIFF_MYBUFFER; } else tif->tif_flags &= ~TIFF_MYBUFFER; - tif->tif_rawdata = (uint8*) bp; + tif->tif_rawdata = (uint8_t*) bp; tif->tif_rawdatasize = size; tif->tif_rawcc = 0; tif->tif_rawcp = tif->tif_rawdata; @@ -700,17 +700,17 @@ TIFFWriteBufferSetup(TIFF* tif, void* bp, tmsize_t size) * Grow the strip data structures by delta strips. */ static int -TIFFGrowStrips(TIFF* tif, uint32 delta, const char* module) +TIFFGrowStrips(TIFF* tif, uint32_t delta, const char* module) { TIFFDirectory *td = &tif->tif_dir; - uint64* new_stripoffset; - uint64* new_stripbytecount; + uint64_t* new_stripoffset; + uint64_t* new_stripbytecount; assert(td->td_planarconfig == PLANARCONFIG_CONTIG); - new_stripoffset = (uint64*)_TIFFrealloc(td->td_stripoffset_p, - (td->td_nstrips + delta) * sizeof (uint64)); - new_stripbytecount = (uint64*)_TIFFrealloc(td->td_stripbytecount_p, - (td->td_nstrips + delta) * sizeof (uint64)); + new_stripoffset = (uint64_t*)_TIFFrealloc(td->td_stripoffset_p, + (td->td_nstrips + delta) * sizeof (uint64_t)); + new_stripbytecount = (uint64_t*)_TIFFrealloc(td->td_stripbytecount_p, + (td->td_nstrips + delta) * sizeof (uint64_t)); if (new_stripoffset == NULL || new_stripbytecount == NULL) { if (new_stripoffset) _TIFFfree(new_stripoffset); @@ -723,9 +723,9 @@ TIFFGrowStrips(TIFF* tif, uint32 delta, const char* module) td->td_stripoffset_p = new_stripoffset; td->td_stripbytecount_p = new_stripbytecount; _TIFFmemset(td->td_stripoffset_p + td->td_nstrips, - 0, delta*sizeof (uint64)); + 0, delta*sizeof (uint64_t)); _TIFFmemset(td->td_stripbytecount_p + td->td_nstrips, - 0, delta*sizeof (uint64)); + 0, delta*sizeof (uint64_t)); td->td_nstrips += delta; tif->tif_flags |= TIFF_DIRTYDIRECT; @@ -736,19 +736,19 @@ TIFFGrowStrips(TIFF* tif, uint32 delta, const char* module) * Append the data to the specified strip. */ static int -TIFFAppendToStrip(TIFF* tif, uint32 strip, uint8* data, tmsize_t cc) +TIFFAppendToStrip(TIFF* tif, uint32_t strip, uint8_t* data, tmsize_t cc) { static const char module[] = "TIFFAppendToStrip"; TIFFDirectory *td = &tif->tif_dir; - uint64 m; - int64 old_byte_count = -1; + uint64_t m; + int64_t old_byte_count = -1; if (td->td_stripoffset_p[strip] == 0 || tif->tif_curoff == 0) { assert(td->td_nstrips > 0); if( td->td_stripbytecount_p[strip] != 0 && td->td_stripoffset_p[strip] != 0 - && td->td_stripbytecount_p[strip] >= (uint64) cc ) + && td->td_stripbytecount_p[strip] >= (uint64_t) cc ) { /* * There is already tile data on disk, and the new tile @@ -785,8 +785,8 @@ TIFFAppendToStrip(TIFF* tif, uint32 strip, uint8* data, tmsize_t cc) m = tif->tif_curoff+cc; if (!(tif->tif_flags&TIFF_BIGTIFF)) - m = (uint32)m; - if ((m<tif->tif_curoff)||(m<(uint64)cc)) + m = (uint32_t)m; + if ((m<tif->tif_curoff)||(m<(uint64_t)cc)) { TIFFErrorExt(tif->tif_clientdata, module, "Maximum TIFF file size exceeded"); return (0); @@ -799,7 +799,7 @@ TIFFAppendToStrip(TIFF* tif, uint32 strip, uint8* data, tmsize_t cc) tif->tif_curoff = m; td->td_stripbytecount_p[strip] += cc; - if( (int64) td->td_stripbytecount_p[strip] != old_byte_count ) + if((int64_t) td->td_stripbytecount_p[strip] != old_byte_count ) tif->tif_flags |= TIFF_DIRTYSTRIP; return (1); @@ -816,7 +816,7 @@ TIFFFlushData1(TIFF* tif) if (tif->tif_rawcc > 0 && tif->tif_flags & TIFF_BUF4WRITE ) { if (!isFillOrder(tif, tif->tif_dir.td_fillorder) && (tif->tif_flags & TIFF_NOBITREV) == 0) - TIFFReverseBits((uint8*)tif->tif_rawdata, + TIFFReverseBits((uint8_t*)tif->tif_rawdata, tif->tif_rawcc); if (!TIFFAppendToStrip(tif, isTiled(tif) ? tif->tif_curtile : tif->tif_curstrip, diff --git a/tiff/libtiff/tif_zip.c b/tiff/libtiff/tif_zip.c index e71c312c..be35e49b 100644 --- a/tiff/libtiff/tif_zip.c +++ b/tiff/libtiff/tif_zip.c @@ -85,8 +85,8 @@ typedef struct { #define DecoderState(tif) ZState(tif) #define EncoderState(tif) ZState(tif) -static int ZIPEncode(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s); -static int ZIPDecode(TIFF* tif, uint8* op, tmsize_t occ, uint16 s); +static int ZIPEncode(TIFF* tif, uint8_t* bp, tmsize_t cc, uint16_t s); +static int ZIPDecode(TIFF* tif, uint8_t* op, tmsize_t occ, uint16_t s); static int ZIPFixupTags(TIFF* tif) @@ -126,7 +126,7 @@ ZIPSetupDecode(TIFF* tif) * Setup state for decoding a strip. */ static int -ZIPPreDecode(TIFF* tif, uint16 s) +ZIPPreDecode(TIFF* tif, uint16_t s) { ZIPState* sp = DecoderState(tif); @@ -144,12 +144,12 @@ ZIPPreDecode(TIFF* tif, uint16 s) we need to simplify this code to reflect a ZLib that is likely updated to deal with 8byte memory sizes, though this code will respond appropriately even before we simplify it */ - sp->stream.avail_in = (uint64)tif->tif_rawcc < 0xFFFFFFFFU ? (uInt) tif->tif_rawcc : 0xFFFFFFFFU; + sp->stream.avail_in = (uint64_t)tif->tif_rawcc < 0xFFFFFFFFU ? (uInt) tif->tif_rawcc : 0xFFFFFFFFU; return (inflateReset(&sp->stream) == Z_OK); } static int -ZIPDecode(TIFF* tif, uint8* op, tmsize_t occ, uint16 s) +ZIPDecode(TIFF* tif, uint8_t* op, tmsize_t occ, uint16_t s) { static const char module[] = "ZIPDecode"; ZIPState* sp = DecoderState(tif); @@ -174,20 +174,20 @@ ZIPDecode(TIFF* tif, uint8* op, tmsize_t occ, uint16 s) /* Check if we are in the situation where we can use libdeflate */ if (isTiled(tif)) { - if( TIFFTileSize64(tif) != (uint64)occ ) + if( TIFFTileSize64(tif) != (uint64_t)occ ) break; } else { - uint32 strip_height = td->td_imagelength - tif->tif_row; + uint32_t strip_height = td->td_imagelength - tif->tif_row; if (strip_height > td->td_rowsperstrip) strip_height = td->td_rowsperstrip; - if( TIFFVStripSize64(tif, strip_height) != (uint64)occ ) + if( TIFFVStripSize64(tif, strip_height) != (uint64_t)occ ) break; } /* Check for overflow */ - if( (size_t)tif->tif_rawcc != (uint64)tif->tif_rawcc ) + if( (size_t)tif->tif_rawcc != (uint64_t)tif->tif_rawcc ) break; - if( (size_t)occ != (uint64)occ ) + if( (size_t)occ != (uint64_t)occ ) break; /* Go for decompression using libdeflate */ @@ -238,8 +238,8 @@ ZIPDecode(TIFF* tif, uint8* op, tmsize_t occ, uint16 s) appropriately even before we simplify it */ do { int state; - uInt avail_in_before = (uint64)tif->tif_rawcc <= 0xFFFFFFFFU ? (uInt)tif->tif_rawcc : 0xFFFFFFFFU; - uInt avail_out_before = (uint64)occ < 0xFFFFFFFFU ? (uInt) occ : 0xFFFFFFFFU; + uInt avail_in_before = (uint64_t)tif->tif_rawcc <= 0xFFFFFFFFU ? (uInt)tif->tif_rawcc : 0xFFFFFFFFU; + uInt avail_out_before = (uint64_t)occ < 0xFFFFFFFFU ? (uInt) occ : 0xFFFFFFFFU; sp->stream.avail_in = avail_in_before; sp->stream.avail_out = avail_out_before; state = inflate(&sp->stream, Z_PARTIAL_FLUSH); @@ -261,8 +261,8 @@ ZIPDecode(TIFF* tif, uint8* op, tmsize_t occ, uint16 s) } while (occ > 0); if (occ != 0) { TIFFErrorExt(tif->tif_clientdata, module, - "Not enough data at scanline %lu (short " TIFF_UINT64_FORMAT " bytes)", - (unsigned long) tif->tif_row, (TIFF_UINT64_T) occ); + "Not enough data at scanline %lu (short %" PRIu64 " bytes)", + (unsigned long) tif->tif_row, (uint64_t) occ); return (0); } @@ -301,7 +301,7 @@ ZIPSetupEncode(TIFF* tif) * Reset encoding state at the start of a strip. */ static int -ZIPPreEncode(TIFF* tif, uint16 s) +ZIPPreEncode(TIFF* tif, uint16_t s) { ZIPState *sp = EncoderState(tif); @@ -318,7 +318,7 @@ ZIPPreEncode(TIFF* tif, uint16 s) we need to simplify this code to reflect a ZLib that is likely updated to deal with 8byte memory sizes, though this code will respond appropriately even before we simplify it */ - sp->stream.avail_out = (uint64)tif->tif_rawdatasize <= 0xFFFFFFFFU ? (uInt)tif->tif_rawdatasize : 0xFFFFFFFFU; + sp->stream.avail_out = (uint64_t)tif->tif_rawdatasize <= 0xFFFFFFFFU ? (uInt)tif->tif_rawdatasize : 0xFFFFFFFFU; return (deflateReset(&sp->stream) == Z_OK); } @@ -326,7 +326,7 @@ ZIPPreEncode(TIFF* tif, uint16 s) * Encode a chunk of pixels. */ static int -ZIPEncode(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) +ZIPEncode(TIFF* tif, uint8_t* bp, tmsize_t cc, uint16_t s) { static const char module[] = "ZIPEncode"; ZIPState *sp = EncoderState(tif); @@ -356,20 +356,20 @@ ZIPEncode(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) /* Check if we are in the situation where we can use libdeflate */ if (isTiled(tif)) { - if( TIFFTileSize64(tif) != (uint64)cc ) + if( TIFFTileSize64(tif) != (uint64_t)cc ) break; } else { - uint32 strip_height = td->td_imagelength - tif->tif_row; + uint32_t strip_height = td->td_imagelength - tif->tif_row; if (strip_height > td->td_rowsperstrip) strip_height = td->td_rowsperstrip; - if( TIFFVStripSize64(tif, strip_height) != (uint64)cc ) + if( TIFFVStripSize64(tif, strip_height) != (uint64_t)cc ) break; } /* Check for overflow */ - if( (size_t)tif->tif_rawdatasize != (uint64)tif->tif_rawdatasize ) + if( (size_t)tif->tif_rawdatasize != (uint64_t)tif->tif_rawdatasize ) break; - if( (size_t)cc != (uint64)cc ) + if( (size_t)cc != (uint64_t)cc ) break; /* Go for compression using libdeflate */ @@ -430,7 +430,7 @@ ZIPEncode(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) to deal with 8byte memory sizes, though this code will respond appropriately even before we simplify it */ do { - uInt avail_in_before = (uint64)cc <= 0xFFFFFFFFU ? (uInt)cc : 0xFFFFFFFFU; + uInt avail_in_before = (uint64_t)cc <= 0xFFFFFFFFU ? (uInt)cc : 0xFFFFFFFFU; sp->stream.avail_in = avail_in_before; if (deflate(&sp->stream, Z_NO_FLUSH) != Z_OK) { TIFFErrorExt(tif->tif_clientdata, module, @@ -443,7 +443,7 @@ ZIPEncode(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) if (!TIFFFlushData1(tif)) return 0; sp->stream.next_out = tif->tif_rawdata; - sp->stream.avail_out = (uint64)tif->tif_rawdatasize <= 0xFFFFFFFFU ? (uInt)tif->tif_rawdatasize : 0xFFFFFFFFU; + sp->stream.avail_out = (uint64_t)tif->tif_rawdatasize <= 0xFFFFFFFFU ? (uInt)tif->tif_rawdatasize : 0xFFFFFFFFU; } cc -= (avail_in_before - sp->stream.avail_in); } while (cc > 0); @@ -478,7 +478,7 @@ ZIPPostEncode(TIFF* tif) if (!TIFFFlushData1(tif)) return 0; sp->stream.next_out = tif->tif_rawdata; - sp->stream.avail_out = (uint64)tif->tif_rawdatasize <= 0xFFFFFFFFU ? (uInt)tif->tif_rawdatasize : 0xFFFFFFFFU; + sp->stream.avail_out = (uint64_t)tif->tif_rawdatasize <= 0xFFFFFFFFU ? (uInt)tif->tif_rawdatasize : 0xFFFFFFFFU; } break; default: @@ -524,7 +524,7 @@ ZIPCleanup(TIFF* tif) } static int -ZIPVSetField(TIFF* tif, uint32 tag, va_list ap) +ZIPVSetField(TIFF* tif, uint32_t tag, va_list ap) { static const char module[] = "ZIPVSetField"; ZIPState* sp = ZState(tif); @@ -588,7 +588,7 @@ ZIPVSetField(TIFF* tif, uint32 tag, va_list ap) } static int -ZIPVGetField(TIFF* tif, uint32 tag, va_list ap) +ZIPVGetField(TIFF* tif, uint32_t tag, va_list ap) { ZIPState* sp = ZState(tif); @@ -636,7 +636,7 @@ TIFFInitZIP(TIFF* tif, int scheme) /* * Allocate state block so tag methods have storage to record values. */ - tif->tif_data = (uint8*) _TIFFcalloc(sizeof (ZIPState), 1); + tif->tif_data = (uint8_t*) _TIFFcalloc(sizeof (ZIPState), 1); if (tif->tif_data == NULL) goto bad; sp = ZState(tif); diff --git a/tiff/libtiff/tif_zstd.c b/tiff/libtiff/tif_zstd.c index 66135e03..14ac0811 100644 --- a/tiff/libtiff/tif_zstd.c +++ b/tiff/libtiff/tif_zstd.c @@ -57,8 +57,8 @@ typedef struct { #define DecoderState(tif) LState(tif) #define EncoderState(tif) LState(tif) -static int ZSTDEncode(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s); -static int ZSTDDecode(TIFF* tif, uint8* op, tmsize_t occ, uint16 s); +static int ZSTDEncode(TIFF* tif, uint8_t* bp, tmsize_t cc, uint16_t s); +static int ZSTDDecode(TIFF* tif, uint8_t* op, tmsize_t occ, uint16_t s); static int ZSTDFixupTags(TIFF* tif) @@ -89,7 +89,7 @@ ZSTDSetupDecode(TIFF* tif) * Setup state for decoding a strip. */ static int -ZSTDPreDecode(TIFF* tif, uint16 s) +ZSTDPreDecode(TIFF* tif, uint16_t s) { static const char module[] = "ZSTDPreDecode"; ZSTDState* sp = DecoderState(tif); @@ -125,7 +125,7 @@ ZSTDPreDecode(TIFF* tif, uint16 s) } static int -ZSTDDecode(TIFF* tif, uint8* op, tmsize_t occ, uint16 s) +ZSTDDecode(TIFF* tif, uint8_t* op, tmsize_t occ, uint16_t s) { static const char module[] = "ZSTDDecode"; ZSTDState* sp = DecoderState(tif); @@ -192,7 +192,7 @@ ZSTDSetupEncode(TIFF* tif) * Reset encoding state at the start of a strip. */ static int -ZSTDPreEncode(TIFF* tif, uint16 s) +ZSTDPreEncode(TIFF* tif, uint16_t s) { static const char module[] = "ZSTDPreEncode"; ZSTDState *sp = EncoderState(tif); @@ -233,7 +233,7 @@ ZSTDPreEncode(TIFF* tif, uint16 s) * Encode a chunk of pixels. */ static int -ZSTDEncode(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) +ZSTDEncode(TIFF* tif, uint8_t* bp, tmsize_t cc, uint16_t s) { static const char module[] = "ZSTDEncode"; ZSTDState *sp = EncoderState(tif); @@ -326,7 +326,7 @@ ZSTDCleanup(TIFF* tif) } static int -ZSTDVSetField(TIFF* tif, uint32 tag, va_list ap) +ZSTDVSetField(TIFF* tif, uint32_t tag, va_list ap) { static const char module[] = "ZSTDVSetField"; ZSTDState* sp = LState(tif); @@ -349,7 +349,7 @@ ZSTDVSetField(TIFF* tif, uint32 tag, va_list ap) } static int -ZSTDVGetField(TIFF* tif, uint32 tag, va_list ap) +ZSTDVGetField(TIFF* tif, uint32_t tag, va_list ap) { ZSTDState* sp = LState(tif); @@ -375,6 +375,7 @@ TIFFInitZSTD(TIFF* tif, int scheme) static const char module[] = "TIFFInitZSTD"; ZSTDState* sp; + (void) scheme; assert( scheme == COMPRESSION_ZSTD ); /* @@ -389,7 +390,7 @@ TIFFInitZSTD(TIFF* tif, int scheme) /* * Allocate state block so tag methods have storage to record values. */ - tif->tif_data = (uint8*) _TIFFmalloc(sizeof(ZSTDState)); + tif->tif_data = (uint8_t*) _TIFFmalloc(sizeof(ZSTDState)); if (tif->tif_data == NULL) goto bad; sp = LState(tif); diff --git a/tiff/libtiff/tiff.h b/tiff/libtiff/tiff.h index 2d4a4767..bd79270c 100644 --- a/tiff/libtiff/tiff.h +++ b/tiff/libtiff/tiff.h @@ -56,24 +56,37 @@ /* * Intrinsic data types required by the file format: * - * 8-bit quantities int8/uint8 - * 16-bit quantities int16/uint16 - * 32-bit quantities int32/uint32 - * 64-bit quantities int64/uint64 + * 8-bit quantities int8_t/uint_8_t + * 16-bit quantities int16_t/uint_16_t + * 32-bit quantities int32_t/uint_32_t + * 64-bit quantities int64_t/uint_64_t * strings unsigned char* */ +#ifdef __GNUC__ +#define TIFF_GCC_DEPRECATED __attribute__((deprecated)) +#else +#define TIFF_GCC_DEPRECATED +#endif +#ifdef _MSC_VER +#define TIFF_MSC_DEPRECATED __declspec(deprecated("libtiff type deprecated; please use corresponding C99 stdint.h type")) +#else +#define TIFF_MSC_DEPRECATED +#endif -typedef TIFF_INT8_T int8; -typedef TIFF_UINT8_T uint8; +#ifndef TIFF_DISABLE_DEPRECATED +typedef TIFF_MSC_DEPRECATED int8_t int8 TIFF_GCC_DEPRECATED; +typedef TIFF_MSC_DEPRECATED uint8_t uint8 TIFF_GCC_DEPRECATED; -typedef TIFF_INT16_T int16; -typedef TIFF_UINT16_T uint16; +typedef TIFF_MSC_DEPRECATED int16_t int16 TIFF_GCC_DEPRECATED; +typedef TIFF_MSC_DEPRECATED uint16_t uint16 TIFF_GCC_DEPRECATED; -typedef TIFF_INT32_T int32; -typedef TIFF_UINT32_T uint32; +typedef TIFF_MSC_DEPRECATED int32_t int32 TIFF_GCC_DEPRECATED; +typedef TIFF_MSC_DEPRECATED uint32_t uint32 TIFF_GCC_DEPRECATED; + +typedef TIFF_MSC_DEPRECATED int64_t int64 TIFF_GCC_DEPRECATED; +typedef TIFF_MSC_DEPRECATED uint64_t uint64 TIFF_GCC_DEPRECATED; +#endif /* TIFF_DISABLE_DEPRECATED */ -typedef TIFF_INT64_T int64; -typedef TIFF_UINT64_T uint64; /* * Some types as promoted in a variable argument list @@ -89,20 +102,20 @@ typedef int uint16_vap; * TIFF header. */ typedef struct { - uint16 tiff_magic; /* magic number (defines byte order) */ - uint16 tiff_version; /* TIFF version number */ + uint16_t tiff_magic; /* magic number (defines byte order) */ + uint16_t tiff_version; /* TIFF version number */ } TIFFHeaderCommon; typedef struct { - uint16 tiff_magic; /* magic number (defines byte order) */ - uint16 tiff_version; /* TIFF version number */ - uint32 tiff_diroff; /* byte offset to first directory */ + uint16_t tiff_magic; /* magic number (defines byte order) */ + uint16_t tiff_version; /* TIFF version number */ + uint32_t tiff_diroff; /* byte offset to first directory */ } TIFFHeaderClassic; typedef struct { - uint16 tiff_magic; /* magic number (defines byte order) */ - uint16 tiff_version; /* TIFF version number */ - uint16 tiff_offsetsize; /* size of offsets, should be 8 */ - uint16 tiff_unused; /* unused word, should be 0 */ - uint64 tiff_diroff; /* byte offset to first directory */ + uint16_t tiff_magic; /* magic number (defines byte order) */ + uint16_t tiff_version; /* TIFF version number */ + uint16_t tiff_offsetsize; /* size of offsets, should be 8 */ + uint16_t tiff_unused; /* unused word, should be 0 */ + uint64_t tiff_diroff; /* byte offset to first directory */ } TIFFHeaderBig; @@ -197,6 +210,7 @@ typedef enum { #define COMPRESSION_LZMA 34925 /* LZMA2 */ #define COMPRESSION_ZSTD 50000 /* ZSTD: WARNING not registered in Adobe-maintained registry */ #define COMPRESSION_WEBP 50001 /* WEBP: WARNING not registered in Adobe-maintained registry */ +#define COMPRESSION_JXL 50002 /* JPEGXL: WARNING not registered in Adobe-maintained registry */ #define TIFFTAG_PHOTOMETRIC 262 /* photometric interpretation */ #define PHOTOMETRIC_MINISWHITE 0 /* min value is white */ #define PHOTOMETRIC_MINISBLACK 1 /* min value is black */ @@ -465,7 +479,7 @@ typedef enum { #define TIFFTAG_JBIGOPTIONS 34750 /* JBIG options */ #define TIFFTAG_GPSIFD 34853 /* Pointer to GPS private directory */ /* tags 34908-34914 are private tags registered to SGI */ -#define TIFFTAG_FAXRECVPARAMS 34908 /* encoded Class 2 ses. parms */ +#define TIFFTAG_FAXRECVPARAMS 34908 /* encoded Class 2 ses. params */ #define TIFFTAG_FAXSUBADDRESS 34909 /* received SubAddr string */ #define TIFFTAG_FAXRECVTIME 34910 /* receive time (secs) */ #define TIFFTAG_FAXDCS 34911 /* encoded fax ses. params, Table 2/T.30 */ diff --git a/tiff/libtiff/tiffconf.h.cmake.in b/tiff/libtiff/tiffconf.h.cmake.in index 9b4b0328..66ab3541 100644 --- a/tiff/libtiff/tiffconf.h.cmake.in +++ b/tiff/libtiff/tiffconf.h.cmake.in @@ -7,6 +7,12 @@ #ifndef _TIFFCONF_ #define _TIFFCONF_ + +#include <stddef.h> +#include <stdint.h> +#include <inttypes.h> + + /* Signed 16-bit type */ #define TIFF_INT16_T @TIFF_INT16_T@ @@ -31,18 +37,12 @@ /* Unsigned 8-bit type */ #define TIFF_UINT8_T @TIFF_UINT8_T@ -/* Unsigned size type */ -#define TIFF_SIZE_T @TIFF_SIZE_T@ - /* Signed size type */ #define TIFF_SSIZE_T @TIFF_SSIZE_T@ -/* Pointer difference type */ -#define TIFF_PTRDIFF_T @TIFF_PTRDIFF_T@ - /* Compatibility stuff. */ -/* Define as 0 or 1 according to the floating point format suported by the +/* Define as 0 or 1 according to the floating point format supported by the machine */ #cmakedefine HAVE_IEEEFP 1 @@ -62,6 +62,9 @@ /* Support JBIG compression (requires JBIG-KIT library) */ #cmakedefine JBIG_SUPPORT +/* Support LERC compression */ +#cmakedefine LERC_SUPPORT 1 + /* Support LogLuv high dynamic range encoding */ #cmakedefine LOGLUV_SUPPORT 1 @@ -91,7 +94,7 @@ #cmakedefine LIBDEFLATE_SUPPORT 1 /* Support strip chopping (whether or not to convert single-strip uncompressed - images to mutiple strips of ~8Kb to reduce memory usage) */ + images to multiple strips of ~8Kb to reduce memory usage) */ #cmakedefine STRIPCHOP_DEFAULT 1 /* Enable SubIFD tag (330) support */ diff --git a/tiff/libtiff/tiffconf.h.in b/tiff/libtiff/tiffconf.h.in index 9bd6a2de..6703eb0e 100644 --- a/tiff/libtiff/tiffconf.h.in +++ b/tiff/libtiff/tiffconf.h.in @@ -7,6 +7,12 @@ #ifndef _TIFFCONF_ #define _TIFFCONF_ + +#include <stddef.h> +#include <stdint.h> +#include <inttypes.h> + + /* Signed 16-bit type */ #undef TIFF_INT16_T @@ -34,12 +40,9 @@ /* Signed size type */ #undef TIFF_SSIZE_T -/* Pointer difference type */ -#undef TIFF_PTRDIFF_T - /* Compatibility stuff. */ -/* Define as 0 or 1 according to the floating point format suported by the +/* Define as 0 or 1 according to the floating point format supported by the machine */ #undef HAVE_IEEEFP @@ -59,6 +62,9 @@ /* Support JBIG compression (requires JBIG-KIT library) */ #undef JBIG_SUPPORT +/* Support LERC compression */ +#undef LERC_SUPPORT + /* Support LogLuv high dynamic range encoding */ #undef LOGLUV_SUPPORT @@ -88,7 +94,7 @@ #undef LIBDEFLATE_SUPPORT /* Support strip chopping (whether or not to convert single-strip uncompressed - images to mutiple strips of ~8Kb to reduce memory usage) */ + images to multiple strips of ~8Kb to reduce memory usage) */ #undef STRIPCHOP_DEFAULT /* Enable SubIFD tag (330) support */ diff --git a/tiff/libtiff/tiffconf.vc.h b/tiff/libtiff/tiffconf.vc.h index fb37a755..94f637bf 100644 --- a/tiff/libtiff/tiffconf.vc.h +++ b/tiff/libtiff/tiffconf.vc.h @@ -142,6 +142,84 @@ #define PHOTOSHOP_SUPPORT #define IPTC_SUPPORT + +typedef char int8_t; +typedef unsigned char uint8_t; +typedef short int16_t; +typedef unsigned short uint16_t; +typedef int int32_t; +typedef unsigned int uint32_t; +typedef long long int64_t; +typedef unsigned long long uint64_t; + +#ifndef UINT32_MAX +#define UINT32_MAX 0xFFFFFFFF +#endif + +#ifndef UINT64_MAX +#define UINT64_MAX 0xFFFFFFFFFFFFFFFF +#endif + +#ifndef INT64_MAX +#define INT64_MAX 0x7FFFFFFFFFFFFFFF +#endif + +#ifndef SIZE_MAX +#if _WIN64 +#define SIZE_MAX UINT64_MAX +#else +#define SIZE_MAX UINT32_MAX +#endif +#endif + +#ifndef PRIu8 +#define PRIu8 "u" +#endif + +#ifndef PRId8 +#define PRId8 "d" +#endif + +#ifndef PRIx8 +#define PRIx8 "x" +#endif + +#ifndef PRIu16 +#define PRIu16 "u" +#endif + +#ifndef PRId16 +#define PRId16 "d" +#endif + +#ifndef PRIx16 +#define PRIx16 "x" +#endif + +#ifndef PRIu32 +#define PRIu32 "u" +#endif + +#ifndef PRId32 +#define PRId32 "d" +#endif + +#ifndef PRIx32 +#define PRIx32 "x" +#endif + +#ifndef PRIu64 +#define PRIu64 "llu" +#endif + +#ifndef PRId64 +#define PRId64 "lld" +#endif + +#ifndef PRIx64 +#define PRIx64 "llx" +#endif + #endif /* _TIFFCONF_ */ /* * Local Variables: diff --git a/tiff/libtiff/tiffconf.wince.h b/tiff/libtiff/tiffconf.wince.h deleted file mode 100644 index 013b0960..00000000 --- a/tiff/libtiff/tiffconf.wince.h +++ /dev/null @@ -1,110 +0,0 @@ -/* - * 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_ - -/* The size of a `int', as computed by sizeof. */ -#define SIZEOF_INT 4 - -/* 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: - */ diff --git a/tiff/libtiff/tiffio.h b/tiff/libtiff/tiffio.h index a4512434..ba6b853b 100644 --- a/tiff/libtiff/tiffio.h +++ b/tiff/libtiff/tiffio.h @@ -60,16 +60,18 @@ typedef struct tiff TIFF; */ /* * this is the machine addressing size type, only it's signed, so make it - * int32 on 32bit machines, int64 on 64bit machines + * int32_t on 32bit machines, int64_t on 64bit machines */ typedef TIFF_SSIZE_T tmsize_t; -typedef uint64 toff_t; /* file offset */ +#define TIFF_TMSIZE_T_MAX (tmsize_t)(SIZE_MAX >> 1) + +typedef uint64_t toff_t; /* file offset */ /* the following are deprecated and should be replaced by their defining counterparts */ -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 uint32_t ttag_t; /* directory tag */ +typedef uint16_t tdir_t; /* directory index */ +typedef uint16_t tsample_t; /* sample number */ +typedef uint32_t tstrile_t; /* strip or tile number */ typedef tstrile_t tstrip_t; /* strip number */ typedef tstrile_t ttile_t; /* tile number */ typedef tmsize_t tsize_t; /* i/o size in bytes */ @@ -140,9 +142,9 @@ typedef struct { float d_YCR; /* Light o/p for reference white */ float d_YCG; float d_YCB; - uint32 d_Vrwr; /* Pixel values for ref. white */ - uint32 d_Vrwg; - uint32 d_Vrwb; + uint32_t d_Vrwr; /* Pixel values for ref. white */ + uint32_t d_Vrwg; + uint32_t d_Vrwb; float d_Y0R; /* Residual light for black pixel */ float d_Y0G; float d_Y0B; @@ -155,9 +157,9 @@ typedef struct { /* YCbCr->RGB support */ TIFFRGBValue* clamptab; /* range clamping table */ int* Cr_r_tab; int* Cb_b_tab; - int32* Cr_g_tab; - int32* Cb_g_tab; - int32* Y_tab; + int32_t* Cr_g_tab; + int32_t* Cb_g_tab; + int32_t* Y_tab; } TIFFYCbCrToRGB; typedef struct { /* CIE Lab 1976->RGB support */ @@ -186,11 +188,11 @@ typedef struct _TIFFRGBAImage TIFFRGBAImage; * and draw the unpacked raster on the display. */ typedef void (*tileContigRoutine) - (TIFFRGBAImage*, uint32*, uint32, uint32, uint32, uint32, int32, int32, - unsigned char*); + (TIFFRGBAImage*, uint32_t*, uint32_t, uint32_t, uint32_t, uint32_t, int32_t, int32_t, + unsigned char*); typedef void (*tileSeparateRoutine) - (TIFFRGBAImage*, uint32*, uint32, uint32, uint32, uint32, int32, int32, - unsigned char*, unsigned char*, unsigned char*, unsigned char*); + (TIFFRGBAImage*, uint32_t*, uint32_t, uint32_t, uint32_t, uint32_t, int32_t, int32_t, + unsigned char*, unsigned char*, unsigned char*, unsigned char*); /* * RGBA-reader state. */ @@ -199,18 +201,18 @@ struct _TIFFRGBAImage { int stoponerr; /* stop on read error */ int isContig; /* data is packed/separate */ int alpha; /* type of alpha data present */ - uint32 width; /* image width */ - uint32 height; /* image height */ - uint16 bitspersample; /* image bits/sample */ - uint16 samplesperpixel; /* image samples/pixel */ - uint16 orientation; /* image orientation */ - uint16 req_orientation; /* requested orientation */ - uint16 photometric; /* image photometric interp */ - uint16* redcmap; /* colormap palette */ - uint16* greencmap; - uint16* bluecmap; + uint32_t width; /* image width */ + uint32_t height; /* image height */ + uint16_t bitspersample; /* image bits/sample */ + uint16_t samplesperpixel; /* image samples/pixel */ + uint16_t orientation; /* image orientation */ + uint16_t req_orientation; /* requested orientation */ + uint16_t photometric; /* image photometric interp */ + uint16_t* redcmap; /* colormap palette */ + uint16_t* greencmap; + uint16_t* bluecmap; /* get image data routine */ - int (*get)(TIFFRGBAImage*, uint32*, uint32, uint32); + int (*get)(TIFFRGBAImage*, uint32_t*, uint32_t, uint32_t); /* put decoded strip/tile */ union { void (*any)(TIFFRGBAImage*); @@ -218,13 +220,13 @@ struct _TIFFRGBAImage { tileSeparateRoutine separate; } put; TIFFRGBValue* Map; /* sample mapping array */ - uint32** BWmap; /* black&white map */ - uint32** PALmap; /* palette image map */ + uint32_t** BWmap; /* black&white map */ + uint32_t** PALmap; /* palette image map */ TIFFYCbCrToRGB* ycbcr; /* YCbCr conversion state */ TIFFCIELabToRGB* cielab; /* CIE L*a*b conversion state */ - uint8* UaToAa; /* Unassociated alpha to associated alpha conversion LUT */ - uint8* Bitdepth16To8; /* LUT for conversion from 16bit to 8bit values */ + uint8_t* UaToAa; /* Unassociated alpha to associated alpha conversion LUT */ + uint8_t* Bitdepth16To8; /* LUT for conversion from 16bit to 8bit values */ int row_offset; int col_offset; @@ -249,7 +251,7 @@ struct _TIFFRGBAImage { typedef int (*TIFFInitMethod)(TIFF*, int); typedef struct { char* name; - uint16 scheme; + uint16_t scheme; TIFFInitMethod init; } TIFFCodec; @@ -282,10 +284,10 @@ typedef void (*TIFFExtendProc)(TIFF*); extern const char* TIFFGetVersion(void); -extern const TIFFCodec* TIFFFindCODEC(uint16); -extern TIFFCodec* TIFFRegisterCODEC(uint16, const char*, TIFFInitMethod); +extern const TIFFCodec* TIFFFindCODEC(uint16_t); +extern TIFFCodec* TIFFRegisterCODEC(uint16_t, const char*, TIFFInitMethod); extern void TIFFUnRegisterCODEC(TIFFCodec*); -extern int TIFFIsCODECConfigured(uint16); +extern int TIFFIsCODECConfigured(uint16_t); extern TIFFCodec* TIFFGetConfiguredCODECs(void); /* @@ -304,31 +306,31 @@ extern void _TIFFfree(void* p); ** Stuff, related to tag handling and creating custom tags. */ extern int TIFFGetTagListCount( TIFF * ); -extern uint32 TIFFGetTagListEntry( TIFF *, int tag_index ); +extern uint32_t TIFFGetTagListEntry(TIFF *, int tag_index ); #define TIFF_ANY TIFF_NOTYPE /* for field descriptor searching */ #define TIFF_VARIABLE -1 /* marker for variable length tags */ #define TIFF_SPP -2 /* marker for SamplesPerPixel tags */ -#define TIFF_VARIABLE2 -3 /* marker for uint32 var-length tags */ +#define TIFF_VARIABLE2 -3 /* marker for uint32_t var-length tags */ #define FIELD_CUSTOM 65 typedef struct _TIFFField TIFFField; typedef struct _TIFFFieldArray TIFFFieldArray; -extern const TIFFField* TIFFFindField(TIFF *, uint32, TIFFDataType); -extern const TIFFField* TIFFFieldWithTag(TIFF*, uint32); +extern const TIFFField* TIFFFindField(TIFF *, uint32_t, TIFFDataType); +extern const TIFFField* TIFFFieldWithTag(TIFF*, uint32_t); extern const TIFFField* TIFFFieldWithName(TIFF*, const char *); -extern uint32 TIFFFieldTag(const TIFFField*); +extern uint32_t TIFFFieldTag(const TIFFField*); extern const char* TIFFFieldName(const TIFFField*); extern TIFFDataType TIFFFieldDataType(const TIFFField*); extern int TIFFFieldPassCount(const TIFFField*); extern int TIFFFieldReadCount(const TIFFField*); extern int TIFFFieldWriteCount(const TIFFField*); -typedef int (*TIFFVSetMethod)(TIFF*, uint32, va_list); -typedef int (*TIFFVGetMethod)(TIFF*, uint32, va_list); +typedef int (*TIFFVSetMethod)(TIFF*, uint32_t, va_list); +typedef int (*TIFFVGetMethod)(TIFF*, uint32_t, va_list); typedef void (*TIFFPrintMethod)(TIFF*, FILE*, long); typedef struct { @@ -345,32 +347,32 @@ extern void TIFFCleanup(TIFF* tif); extern void TIFFClose(TIFF* tif); extern int TIFFFlush(TIFF* tif); extern int TIFFFlushData(TIFF* tif); -extern int TIFFGetField(TIFF* tif, uint32 tag, ...); -extern int TIFFVGetField(TIFF* tif, uint32 tag, va_list ap); -extern int TIFFGetFieldDefaulted(TIFF* tif, uint32 tag, ...); -extern int TIFFVGetFieldDefaulted(TIFF* tif, uint32 tag, va_list ap); +extern int TIFFGetField(TIFF* tif, uint32_t tag, ...); +extern int TIFFVGetField(TIFF* tif, uint32_t tag, va_list ap); +extern int TIFFGetFieldDefaulted(TIFF* tif, uint32_t tag, ...); +extern int TIFFVGetFieldDefaulted(TIFF* tif, uint32_t tag, va_list ap); extern int TIFFReadDirectory(TIFF* tif); extern int TIFFReadCustomDirectory(TIFF* tif, toff_t diroff, const TIFFFieldArray* infoarray); extern int TIFFReadEXIFDirectory(TIFF* tif, toff_t diroff); extern int TIFFReadGPSDirectory(TIFF* tif, toff_t diroff); -extern uint64 TIFFScanlineSize64(TIFF* tif); +extern uint64_t TIFFScanlineSize64(TIFF* tif); extern tmsize_t TIFFScanlineSize(TIFF* tif); -extern uint64 TIFFRasterScanlineSize64(TIFF* tif); +extern uint64_t TIFFRasterScanlineSize64(TIFF* tif); extern tmsize_t TIFFRasterScanlineSize(TIFF* tif); -extern uint64 TIFFStripSize64(TIFF* tif); +extern uint64_t TIFFStripSize64(TIFF* tif); extern tmsize_t TIFFStripSize(TIFF* tif); -extern uint64 TIFFRawStripSize64(TIFF* tif, uint32 strip); -extern tmsize_t TIFFRawStripSize(TIFF* tif, uint32 strip); -extern uint64 TIFFVStripSize64(TIFF* tif, uint32 nrows); -extern tmsize_t TIFFVStripSize(TIFF* tif, uint32 nrows); -extern uint64 TIFFTileRowSize64(TIFF* tif); +extern uint64_t TIFFRawStripSize64(TIFF* tif, uint32_t strip); +extern tmsize_t TIFFRawStripSize(TIFF* tif, uint32_t strip); +extern uint64_t TIFFVStripSize64(TIFF* tif, uint32_t nrows); +extern tmsize_t TIFFVStripSize(TIFF* tif, uint32_t nrows); +extern uint64_t TIFFTileRowSize64(TIFF* tif); extern tmsize_t TIFFTileRowSize(TIFF* tif); -extern uint64 TIFFTileSize64(TIFF* tif); +extern uint64_t TIFFTileSize64(TIFF* tif); extern tmsize_t TIFFTileSize(TIFF* tif); -extern uint64 TIFFVTileSize64(TIFF* tif, uint32 nrows); -extern tmsize_t TIFFVTileSize(TIFF* tif, uint32 nrows); -extern uint32 TIFFDefaultStripSize(TIFF* tif, uint32 request); -extern void TIFFDefaultTileSize(TIFF*, uint32*, uint32*); +extern uint64_t TIFFVTileSize64(TIFF* tif, uint32_t nrows); +extern tmsize_t TIFFVTileSize(TIFF* tif, uint32_t nrows); +extern uint32_t TIFFDefaultStripSize(TIFF* tif, uint32_t request); +extern void TIFFDefaultTileSize(TIFF*, uint32_t*, uint32_t*); extern int TIFFFileno(TIFF*); extern int TIFFSetFileno(TIFF*, int); extern thandle_t TIFFClientdata(TIFF*); @@ -389,12 +391,12 @@ extern TIFFCloseProc TIFFGetCloseProc(TIFF*); extern TIFFSizeProc TIFFGetSizeProc(TIFF*); extern TIFFMapFileProc TIFFGetMapFileProc(TIFF*); extern TIFFUnmapFileProc TIFFGetUnmapFileProc(TIFF*); -extern uint32 TIFFCurrentRow(TIFF*); -extern uint16 TIFFCurrentDirectory(TIFF*); -extern uint16 TIFFNumberOfDirectories(TIFF*); -extern uint64 TIFFCurrentDirOffset(TIFF*); -extern uint32 TIFFCurrentStrip(TIFF*); -extern uint32 TIFFCurrentTile(TIFF* tif); +extern uint32_t TIFFCurrentRow(TIFF*); +extern uint16_t TIFFCurrentDirectory(TIFF*); +extern uint16_t TIFFNumberOfDirectories(TIFF*); +extern uint64_t TIFFCurrentDirOffset(TIFF*); +extern uint32_t TIFFCurrentStrip(TIFF*); +extern uint32_t TIFFCurrentTile(TIFF* tif); extern int TIFFReadBufferSetup(TIFF* tif, void* bp, tmsize_t size); extern int TIFFWriteBufferSetup(TIFF* tif, void* bp, tmsize_t size); extern int TIFFSetupStrips(TIFF *); @@ -405,14 +407,14 @@ extern int TIFFCreateCustomDirectory(TIFF*,const TIFFFieldArray*); extern int TIFFCreateEXIFDirectory(TIFF*); extern int TIFFCreateGPSDirectory(TIFF*); extern int TIFFLastDirectory(TIFF*); -extern int TIFFSetDirectory(TIFF*, uint16); -extern int TIFFSetSubDirectory(TIFF*, uint64); -extern int TIFFUnlinkDirectory(TIFF*, uint16); -extern int TIFFSetField(TIFF*, uint32, ...); -extern int TIFFVSetField(TIFF*, uint32, va_list); -extern int TIFFUnsetField(TIFF*, uint32); +extern int TIFFSetDirectory(TIFF*, uint16_t); +extern int TIFFSetSubDirectory(TIFF*, uint64_t); +extern int TIFFUnlinkDirectory(TIFF*, uint16_t); +extern int TIFFSetField(TIFF*, uint32_t, ...); +extern int TIFFVSetField(TIFF*, uint32_t, va_list); +extern int TIFFUnsetField(TIFF*, uint32_t); extern int TIFFWriteDirectory(TIFF *); -extern int TIFFWriteCustomDirectory(TIFF *, uint64 *); +extern int TIFFWriteCustomDirectory(TIFF *, uint64_t *); extern int TIFFCheckpointDirectory(TIFF *); extern int TIFFRewriteDirectory(TIFF *); extern int TIFFDeferStrileArrayWriting(TIFF *); @@ -423,26 +425,26 @@ extern void TIFFSetJpegMemFunction(TIFF *, void *(*fn)(thandle_t)); #if defined(c_plusplus) || defined(__cplusplus) extern void TIFFPrintDirectory(TIFF*, FILE*, long = 0); -extern int TIFFReadScanline(TIFF* tif, void* buf, uint32 row, uint16 sample = 0); -extern int TIFFWriteScanline(TIFF* tif, void* buf, uint32 row, uint16 sample = 0); -extern int TIFFReadRGBAImage(TIFF*, uint32, uint32, uint32*, int = 0); -extern int TIFFReadRGBAImageOriented(TIFF*, uint32, uint32, uint32*, +extern int TIFFReadScanline(TIFF* tif, void* buf, uint32_t row, uint16_t sample = 0); +extern int TIFFWriteScanline(TIFF* tif, void* buf, uint32_t row, uint16_t sample = 0); +extern int TIFFReadRGBAImage(TIFF*, uint32_t, uint32_t, uint32_t*, int = 0); +extern int TIFFReadRGBAImageOriented(TIFF*, uint32_t, uint32_t, uint32_t*, int = ORIENTATION_BOTLEFT, int = 0); #else extern void TIFFPrintDirectory(TIFF*, FILE*, long); -extern int TIFFReadScanline(TIFF* tif, void* buf, uint32 row, uint16 sample); -extern int TIFFWriteScanline(TIFF* tif, void* buf, uint32 row, uint16 sample); -extern int TIFFReadRGBAImage(TIFF*, uint32, uint32, uint32*, int); -extern int TIFFReadRGBAImageOriented(TIFF*, uint32, uint32, uint32*, int, int); +extern int TIFFReadScanline(TIFF* tif, void* buf, uint32_t row, uint16_t sample); +extern int TIFFWriteScanline(TIFF* tif, void* buf, uint32_t row, uint16_t sample); +extern int TIFFReadRGBAImage(TIFF*, uint32_t, uint32_t, uint32_t*, int); +extern int TIFFReadRGBAImageOriented(TIFF*, uint32_t, uint32_t, uint32_t*, int, int); #endif -extern int TIFFReadRGBAStrip(TIFF*, uint32, uint32 * ); -extern int TIFFReadRGBATile(TIFF*, uint32, uint32, uint32 * ); -extern int TIFFReadRGBAStripExt(TIFF*, uint32, uint32 *, int stop_on_error ); -extern int TIFFReadRGBATileExt(TIFF*, uint32, uint32, uint32 *, int stop_on_error ); +extern int TIFFReadRGBAStrip(TIFF*, uint32_t, uint32_t * ); +extern int TIFFReadRGBATile(TIFF*, uint32_t, uint32_t, uint32_t * ); +extern int TIFFReadRGBAStripExt(TIFF*, uint32_t, uint32_t *, int stop_on_error ); +extern int TIFFReadRGBATileExt(TIFF*, uint32_t, uint32_t, uint32_t *, int stop_on_error ); extern int TIFFRGBAImageOK(TIFF*, char [1024]); extern int TIFFRGBAImageBegin(TIFFRGBAImage*, TIFF*, int, char [1024]); -extern int TIFFRGBAImageGet(TIFFRGBAImage*, uint32*, uint32, uint32); +extern int TIFFRGBAImageGet(TIFFRGBAImage*, uint32_t*, uint32_t, uint32_t); extern void TIFFRGBAImageEnd(TIFFRGBAImage*); extern TIFF* TIFFOpen(const char*, const char*); # ifdef __WIN32__ @@ -466,44 +468,44 @@ extern TIFFErrorHandlerExt TIFFSetErrorHandlerExt(TIFFErrorHandlerExt); extern TIFFErrorHandler TIFFSetWarningHandler(TIFFErrorHandler); extern TIFFErrorHandlerExt TIFFSetWarningHandlerExt(TIFFErrorHandlerExt); extern TIFFExtendProc TIFFSetTagExtender(TIFFExtendProc); -extern uint32 TIFFComputeTile(TIFF* tif, uint32 x, uint32 y, uint32 z, uint16 s); -extern int TIFFCheckTile(TIFF* tif, uint32 x, uint32 y, uint32 z, uint16 s); -extern uint32 TIFFNumberOfTiles(TIFF*); -extern tmsize_t TIFFReadTile(TIFF* tif, void* buf, uint32 x, uint32 y, uint32 z, uint16 s); -extern tmsize_t TIFFWriteTile(TIFF* tif, void* buf, uint32 x, uint32 y, uint32 z, uint16 s); -extern uint32 TIFFComputeStrip(TIFF*, uint32, uint16); -extern uint32 TIFFNumberOfStrips(TIFF*); -extern tmsize_t TIFFReadEncodedStrip(TIFF* tif, uint32 strip, void* buf, tmsize_t size); -extern tmsize_t TIFFReadRawStrip(TIFF* tif, uint32 strip, void* buf, tmsize_t size); -extern tmsize_t TIFFReadEncodedTile(TIFF* tif, uint32 tile, void* buf, tmsize_t size); -extern tmsize_t TIFFReadRawTile(TIFF* tif, uint32 tile, void* buf, tmsize_t size); -extern int TIFFReadFromUserBuffer(TIFF* tif, uint32 strile, +extern uint32_t TIFFComputeTile(TIFF* tif, uint32_t x, uint32_t y, uint32_t z, uint16_t s); +extern int TIFFCheckTile(TIFF* tif, uint32_t x, uint32_t y, uint32_t z, uint16_t s); +extern uint32_t TIFFNumberOfTiles(TIFF*); +extern tmsize_t TIFFReadTile(TIFF* tif, void* buf, uint32_t x, uint32_t y, uint32_t z, uint16_t s); +extern tmsize_t TIFFWriteTile(TIFF* tif, void* buf, uint32_t x, uint32_t y, uint32_t z, uint16_t s); +extern uint32_t TIFFComputeStrip(TIFF*, uint32_t, uint16_t); +extern uint32_t TIFFNumberOfStrips(TIFF*); +extern tmsize_t TIFFReadEncodedStrip(TIFF* tif, uint32_t strip, void* buf, tmsize_t size); +extern tmsize_t TIFFReadRawStrip(TIFF* tif, uint32_t strip, void* buf, tmsize_t size); +extern tmsize_t TIFFReadEncodedTile(TIFF* tif, uint32_t tile, void* buf, tmsize_t size); +extern tmsize_t TIFFReadRawTile(TIFF* tif, uint32_t tile, void* buf, tmsize_t size); +extern int TIFFReadFromUserBuffer(TIFF* tif, uint32_t strile, void* inbuf, tmsize_t insize, void* outbuf, tmsize_t outsize); -extern tmsize_t TIFFWriteEncodedStrip(TIFF* tif, uint32 strip, void* data, tmsize_t cc); -extern tmsize_t TIFFWriteRawStrip(TIFF* tif, uint32 strip, void* data, tmsize_t cc); -extern tmsize_t TIFFWriteEncodedTile(TIFF* tif, uint32 tile, void* data, tmsize_t cc); -extern tmsize_t TIFFWriteRawTile(TIFF* tif, uint32 tile, void* data, tmsize_t cc); +extern tmsize_t TIFFWriteEncodedStrip(TIFF* tif, uint32_t strip, void* data, tmsize_t cc); +extern tmsize_t TIFFWriteRawStrip(TIFF* tif, uint32_t strip, void* data, tmsize_t cc); +extern tmsize_t TIFFWriteEncodedTile(TIFF* tif, uint32_t tile, void* data, tmsize_t cc); +extern tmsize_t TIFFWriteRawTile(TIFF* tif, uint32_t tile, void* data, tmsize_t cc); extern int TIFFDataWidth(TIFFDataType); /* table of tag datatype widths */ extern void TIFFSetWriteOffset(TIFF* tif, toff_t off); -extern void TIFFSwabShort(uint16*); -extern void TIFFSwabLong(uint32*); -extern void TIFFSwabLong8(uint64*); +extern void TIFFSwabShort(uint16_t*); +extern void TIFFSwabLong(uint32_t*); +extern void TIFFSwabLong8(uint64_t*); extern void TIFFSwabFloat(float*); extern void TIFFSwabDouble(double*); -extern void TIFFSwabArrayOfShort(uint16* wp, tmsize_t n); -extern void TIFFSwabArrayOfTriples(uint8* tp, tmsize_t n); -extern void TIFFSwabArrayOfLong(uint32* lp, tmsize_t n); -extern void TIFFSwabArrayOfLong8(uint64* lp, tmsize_t n); +extern void TIFFSwabArrayOfShort(uint16_t* wp, tmsize_t n); +extern void TIFFSwabArrayOfTriples(uint8_t* tp, tmsize_t n); +extern void TIFFSwabArrayOfLong(uint32_t* lp, tmsize_t n); +extern void TIFFSwabArrayOfLong8(uint64_t* lp, tmsize_t n); extern void TIFFSwabArrayOfFloat(float* fp, tmsize_t n); extern void TIFFSwabArrayOfDouble(double* dp, tmsize_t n); -extern void TIFFReverseBits(uint8* cp, tmsize_t n); +extern void TIFFReverseBits(uint8_t* cp, tmsize_t n); extern const unsigned char* TIFFGetBitRevTable(int); -extern uint64 TIFFGetStrileOffset(TIFF *tif, uint32 strile); -extern uint64 TIFFGetStrileByteCount(TIFF *tif, uint32 strile); -extern uint64 TIFFGetStrileOffsetWithErr(TIFF *tif, uint32 strile, int *pbErr); -extern uint64 TIFFGetStrileByteCountWithErr(TIFF *tif, uint32 strile, int *pbErr); +extern uint64_t TIFFGetStrileOffset(TIFF *tif, uint32_t strile); +extern uint64_t TIFFGetStrileByteCount(TIFF *tif, uint32_t strile); +extern uint64_t TIFFGetStrileOffsetWithErr(TIFF *tif, uint32_t strile, int *pbErr); +extern uint64_t TIFFGetStrileByteCountWithErr(TIFF *tif, uint32_t strile, int *pbErr); #ifdef LOGLUV_PUBLIC #define U_NEU 0.210526316 @@ -511,34 +513,34 @@ extern uint64 TIFFGetStrileByteCountWithErr(TIFF *tif, uint32 strile, int *pbErr #define UVSCALE 410. extern double LogL16toY(int); extern double LogL10toY(int); -extern void XYZtoRGB24(float*, uint8*); +extern void XYZtoRGB24(float*, uint8_t*); extern int uv_decode(double*, double*, int); -extern void LogLuv24toXYZ(uint32, float*); -extern void LogLuv32toXYZ(uint32, float*); +extern void LogLuv24toXYZ(uint32_t, float*); +extern void LogLuv32toXYZ(uint32_t, float*); #if defined(c_plusplus) || defined(__cplusplus) extern int LogL16fromY(double, int = SGILOGENCODE_NODITHER); extern int LogL10fromY(double, int = SGILOGENCODE_NODITHER); extern int uv_encode(double, double, int = SGILOGENCODE_NODITHER); -extern uint32 LogLuv24fromXYZ(float*, int = SGILOGENCODE_NODITHER); -extern uint32 LogLuv32fromXYZ(float*, int = SGILOGENCODE_NODITHER); +extern uint32_t LogLuv24fromXYZ(float*, int = SGILOGENCODE_NODITHER); +extern uint32_t LogLuv32fromXYZ(float*, int = SGILOGENCODE_NODITHER); #else extern int LogL16fromY(double, int); extern int LogL10fromY(double, int); extern int uv_encode(double, double, int); -extern uint32 LogLuv24fromXYZ(float*, int); -extern uint32 LogLuv32fromXYZ(float*, int); +extern uint32_t LogLuv24fromXYZ(float*, int); +extern uint32_t LogLuv32fromXYZ(float*, int); #endif #endif /* LOGLUV_PUBLIC */ extern int TIFFCIELabToRGBInit(TIFFCIELabToRGB*, const TIFFDisplay *, float*); -extern void TIFFCIELabToXYZ(TIFFCIELabToRGB *, uint32, int32, int32, - float *, float *, float *); +extern void TIFFCIELabToXYZ(TIFFCIELabToRGB *, uint32_t, int32_t, int32_t, + float *, float *, float *); extern void TIFFXYZToRGB(TIFFCIELabToRGB *, float, float, float, - uint32 *, uint32 *, uint32 *); + uint32_t *, uint32_t *, uint32_t *); extern int TIFFYCbCrToRGBInit(TIFFYCbCrToRGB*, float*, float*); -extern void TIFFYCbCrtoRGB(TIFFYCbCrToRGB *, uint32, int32, int32, - uint32 *, uint32 *, uint32 *); +extern void TIFFYCbCrtoRGB(TIFFYCbCrToRGB *, uint32_t, int32_t, int32_t, + uint32_t *, uint32_t *, uint32_t *); /**************************************************************************** * O B S O L E T E D I N T E R F A C E S @@ -557,7 +559,7 @@ typedef struct { char *field_name; /* ASCII name */ } TIFFFieldInfo; -extern int TIFFMergeFieldInfo(TIFF*, const TIFFFieldInfo[], uint32); +extern int TIFFMergeFieldInfo(TIFF*, const TIFFFieldInfo[], uint32_t); #if defined(c_plusplus) || defined(__cplusplus) } diff --git a/tiff/libtiff/tiffiop.h b/tiff/libtiff/tiffiop.h index b22acb3c..907c05f4 100644 --- a/tiff/libtiff/tiffiop.h +++ b/tiff/libtiff/tiffiop.h @@ -38,9 +38,7 @@ # include <sys/types.h> #endif -#ifdef HAVE_STRING_H -# include <string.h> -#endif +#include <string.h> #ifdef HAVE_ASSERT_H # include <assert.h> @@ -48,19 +46,6 @@ # define assert(x) #endif -#ifdef HAVE_SEARCH_H -# include <search.h> -#else -extern void *lfind(const void *, const void *, size_t *, size_t, - int (*)(const void *, const void *)); -#endif - -#if !defined(HAVE_SNPRINTF) && !defined(HAVE__SNPRINTF) -#undef snprintf -#define snprintf _TIFF_snprintf_f -extern int snprintf(char* str, size_t size, const char* format, ...); -#endif - #include "tiffio.h" #include "tif_dir.h" @@ -77,19 +62,6 @@ extern int snprintf(char* str, size_t size, const char* format, ...); #define FALSE 0 #endif -#define TIFF_SIZE_T_MAX ((size_t) ~ ((size_t)0)) -#define TIFF_TMSIZE_T_MAX (tmsize_t)(TIFF_SIZE_T_MAX >> 1) - -/* - * Largest 32-bit unsigned integer value. - */ -#define TIFF_UINT32_MAX 0xFFFFFFFFU - -/* - * Largest 64-bit unsigned integer value. - */ -#define TIFF_UINT64_MAX (((uint64)(TIFF_UINT32_MAX)) << 32 | TIFF_UINT32_MAX) - typedef struct client_info { struct client_info *next; void *data; @@ -105,18 +77,18 @@ typedef tidataval_t* tidata_t; /* reference to internal image data */ typedef void (*TIFFVoidMethod)(TIFF*); typedef int (*TIFFBoolMethod)(TIFF*); -typedef int (*TIFFPreMethod)(TIFF*, uint16); -typedef int (*TIFFCodeMethod)(TIFF* tif, uint8* buf, tmsize_t size, uint16 sample); -typedef int (*TIFFSeekMethod)(TIFF*, uint32); -typedef void (*TIFFPostMethod)(TIFF* tif, uint8* buf, tmsize_t size); -typedef uint32 (*TIFFStripMethod)(TIFF*, uint32); -typedef void (*TIFFTileMethod)(TIFF*, uint32*, uint32*); +typedef int (*TIFFPreMethod)(TIFF*, uint16_t); +typedef int (*TIFFCodeMethod)(TIFF* tif, uint8_t* buf, tmsize_t size, uint16_t sample); +typedef int (*TIFFSeekMethod)(TIFF*, uint32_t); +typedef void (*TIFFPostMethod)(TIFF* tif, uint8_t* buf, tmsize_t size); +typedef uint32_t (*TIFFStripMethod)(TIFF*, uint32_t); +typedef void (*TIFFTileMethod)(TIFF*, uint32_t*, uint32_t*); struct tiff { char* tif_name; /* name of open file */ int tif_fd; /* open file descriptor */ int tif_mode; /* open mode (O_*) */ - uint32 tif_flags; + uint32_t tif_flags; #define TIFF_FILLORDER 0x00003U /* natural bit fill order for machine */ #define TIFF_DIRTYHEADER 0x00004U /* header must be written on close */ #define TIFF_DIRTYDIRECT 0x00008U /* current directory must be written */ @@ -143,11 +115,11 @@ struct tiff { #define TIFF_DEFERSTRILELOAD 0x1000000U /* defer strip/tile offset/bytecount array loading. */ #define TIFF_LAZYSTRILELOAD 0x2000000U /* lazy/ondemand loading of strip/tile offset/bytecount values. Only used if TIFF_DEFERSTRILELOAD is set and in read-only mode */ #define TIFF_CHOPPEDUPARRAYS 0x4000000U /* set when allocChoppedUpStripArrays() has modified strip array */ - uint64 tif_diroff; /* file offset of current directory */ - uint64 tif_nextdiroff; /* file offset of following directory */ - uint64* tif_dirlist; /* list of offsets to already seen directories to prevent IFD looping */ - uint16 tif_dirlistsize; /* number of entries in offset list */ - uint16 tif_dirnumber; /* number of already seen directories */ + uint64_t tif_diroff; /* file offset of current directory */ + uint64_t tif_nextdiroff; /* file offset of following directory */ + uint64_t* tif_dirlist; /* list of offsets to already seen directories to prevent IFD looping */ + uint16_t tif_dirlistsize; /* number of entries in offset list */ + uint16_t tif_dirnumber; /* number of already seen directories */ TIFFDirectory tif_dir; /* internal rep of current directory */ TIFFDirectory tif_customdir; /* custom IFDs are separated from the main ones */ union { @@ -155,18 +127,18 @@ struct tiff { TIFFHeaderClassic classic; TIFFHeaderBig big; } tif_header; - uint16 tif_header_size; /* file's header block and its length */ - uint32 tif_row; /* current scanline */ - uint16 tif_curdir; /* current directory (index) */ - uint32 tif_curstrip; /* current strip for read/write */ - uint64 tif_curoff; /* current offset for read/write */ - uint64 tif_dataoff; /* current offset for writing dir */ + uint16_t tif_header_size; /* file's header block and its length */ + uint32_t tif_row; /* current scanline */ + uint16_t tif_curdir; /* current directory (index) */ + uint32_t tif_curstrip; /* current strip for read/write */ + uint64_t tif_curoff; /* current offset for read/write */ + uint64_t tif_dataoff; /* current offset for writing dir */ /* SubIFD support */ - uint16 tif_nsubifd; /* remaining subifds to write */ - uint64 tif_subifdoff; /* offset for patching SubIFD link */ + uint16_t tif_nsubifd; /* remaining subifds to write */ + uint64_t tif_subifdoff; /* offset for patching SubIFD link */ /* tiling support */ - uint32 tif_col; /* current column (offset by row too) */ - uint32 tif_curtile; /* current tile for read/write */ + uint32_t tif_col; /* current column (offset by row too) */ + uint32_t tif_curtile; /* current tile for read/write */ tmsize_t tif_tilesize; /* # of bytes in a tile */ /* compression scheme hooks */ int tif_decodestatus; @@ -188,18 +160,18 @@ struct tiff { TIFFVoidMethod tif_cleanup; /* cleanup state routine */ TIFFStripMethod tif_defstripsize; /* calculate/constrain strip size */ TIFFTileMethod tif_deftilesize; /* calculate/constrain tile size */ - uint8* tif_data; /* compression scheme private data */ + uint8_t* tif_data; /* compression scheme private data */ /* input/output buffering */ tmsize_t tif_scanlinesize; /* # of bytes in a scanline */ tmsize_t tif_scanlineskew; /* scanline skew for reading strips */ - uint8* tif_rawdata; /* raw data buffer */ + uint8_t* tif_rawdata; /* raw data buffer */ tmsize_t tif_rawdatasize; /* # of bytes in raw data buffer */ tmsize_t tif_rawdataoff; /* rawdata offset within strip */ tmsize_t tif_rawdataloaded;/* amount of data in rawdata */ - uint8* tif_rawcp; /* current spot in raw buffer */ + uint8_t* tif_rawcp; /* current spot in raw buffer */ tmsize_t tif_rawcc; /* bytes unread from raw buffer */ /* memory-mapped file support */ - uint8* tif_base; /* base of mapped file */ + uint8_t* tif_base; /* base of mapped file */ tmsize_t tif_size; /* size of mapped file region (bytes, thus tmsize_t) */ TIFFMapFileProc tif_mapproc; /* map file method */ TIFFUnmapFileProc tif_unmapproc; /* unmap file method */ @@ -261,18 +233,18 @@ struct tiff { (TIFFWriteFile((tif),(buf),(size))==(size)) #endif -/* NB: the uint32 casts are to silence certain ANSI-C compilers */ -#define TIFFhowmany_32(x, y) (((uint32)x < (0xffffffff - (uint32)(y-1))) ? \ - ((((uint32)(x))+(((uint32)(y))-1))/((uint32)(y))) : \ +/* NB: the uint32_t casts are to silence certain ANSI-C compilers */ +#define TIFFhowmany_32(x, y) (((uint32_t)x < (0xffffffff - (uint32_t)(y-1))) ? \ + ((((uint32_t)(x))+(((uint32_t)(y))-1))/((uint32_t)(y))) : \ 0U) /* Variant of TIFFhowmany_32() that doesn't return 0 if x close to MAXUINT. */ /* Caution: TIFFhowmany_32_maxuint_compat(x,y)*y might overflow */ #define TIFFhowmany_32_maxuint_compat(x, y) \ - (((uint32)(x) / (uint32)(y)) + ((((uint32)(x) % (uint32)(y)) != 0) ? 1 : 0)) -#define TIFFhowmany8_32(x) (((x)&0x07)?((uint32)(x)>>3)+1:(uint32)(x)>>3) + (((uint32_t)(x) / (uint32_t)(y)) + ((((uint32_t)(x) % (uint32_t)(y)) != 0) ? 1 : 0)) +#define TIFFhowmany8_32(x) (((x)&0x07)?((uint32_t)(x)>>3)+1:(uint32_t)(x)>>3) #define TIFFroundup_32(x, y) (TIFFhowmany_32(x,y)*(y)) -#define TIFFhowmany_64(x, y) ((((uint64)(x))+(((uint64)(y))-1))/((uint64)(y))) -#define TIFFhowmany8_64(x) (((x)&0x07)?((uint64)(x)>>3)+1:(uint64)(x)>>3) +#define TIFFhowmany_64(x, y) ((((uint64_t)(x))+(((uint64_t)(y))-1))/((uint64_t)(y))) +#define TIFFhowmany8_64(x) (((x)&0x07)?((uint64_t)(x)>>3)+1:(uint64_t)(x)>>3) #define TIFFroundup_64(x, y) (TIFFhowmany_64(x,y)*(y)) /* Safe multiply which returns zero if there is an *unsigned* integer overflow. This macro is not safe for *signed* integer types */ @@ -345,38 +317,38 @@ typedef size_t TIFFIOSize_t; extern "C" { #endif extern int _TIFFgetMode(const char* mode, const char* module); -extern int _TIFFNoRowEncode(TIFF* tif, uint8* pp, tmsize_t cc, uint16 s); -extern int _TIFFNoStripEncode(TIFF* tif, uint8* pp, tmsize_t cc, uint16 s); -extern int _TIFFNoTileEncode(TIFF*, uint8* pp, tmsize_t cc, uint16 s); -extern int _TIFFNoRowDecode(TIFF* tif, uint8* pp, tmsize_t cc, uint16 s); -extern int _TIFFNoStripDecode(TIFF* tif, uint8* pp, tmsize_t cc, uint16 s); -extern int _TIFFNoTileDecode(TIFF*, uint8* pp, tmsize_t cc, uint16 s); -extern void _TIFFNoPostDecode(TIFF* tif, uint8* buf, tmsize_t cc); -extern int _TIFFNoPreCode(TIFF* tif, uint16 s); -extern int _TIFFNoSeek(TIFF* tif, uint32 off); -extern void _TIFFSwab16BitData(TIFF* tif, uint8* buf, tmsize_t cc); -extern void _TIFFSwab24BitData(TIFF* tif, uint8* buf, tmsize_t cc); -extern void _TIFFSwab32BitData(TIFF* tif, uint8* buf, tmsize_t cc); -extern void _TIFFSwab64BitData(TIFF* tif, uint8* buf, tmsize_t cc); +extern int _TIFFNoRowEncode(TIFF* tif, uint8_t* pp, tmsize_t cc, uint16_t s); +extern int _TIFFNoStripEncode(TIFF* tif, uint8_t* pp, tmsize_t cc, uint16_t s); +extern int _TIFFNoTileEncode(TIFF*, uint8_t* pp, tmsize_t cc, uint16_t s); +extern int _TIFFNoRowDecode(TIFF* tif, uint8_t* pp, tmsize_t cc, uint16_t s); +extern int _TIFFNoStripDecode(TIFF* tif, uint8_t* pp, tmsize_t cc, uint16_t s); +extern int _TIFFNoTileDecode(TIFF*, uint8_t* pp, tmsize_t cc, uint16_t s); +extern void _TIFFNoPostDecode(TIFF* tif, uint8_t* buf, tmsize_t cc); +extern int _TIFFNoPreCode(TIFF* tif, uint16_t s); +extern int _TIFFNoSeek(TIFF* tif, uint32_t off); +extern void _TIFFSwab16BitData(TIFF* tif, uint8_t* buf, tmsize_t cc); +extern void _TIFFSwab24BitData(TIFF* tif, uint8_t* buf, tmsize_t cc); +extern void _TIFFSwab32BitData(TIFF* tif, uint8_t* buf, tmsize_t cc); +extern void _TIFFSwab64BitData(TIFF* tif, uint8_t* buf, tmsize_t cc); extern int TIFFFlushData1(TIFF* tif); extern int TIFFDefaultDirectory(TIFF* tif); extern void _TIFFSetDefaultCompressionState(TIFF* tif); -extern int _TIFFRewriteField(TIFF *, uint16, TIFFDataType, tmsize_t, void *); +extern int _TIFFRewriteField(TIFF *, uint16_t, TIFFDataType, tmsize_t, void *); extern int TIFFSetCompressionScheme(TIFF* tif, int scheme); extern int TIFFSetDefaultCompressionState(TIFF* tif); -extern uint32 _TIFFDefaultStripSize(TIFF* tif, uint32 s); -extern void _TIFFDefaultTileSize(TIFF* tif, uint32* tw, uint32* th); +extern uint32_t _TIFFDefaultStripSize(TIFF* tif, uint32_t s); +extern void _TIFFDefaultTileSize(TIFF* tif, uint32_t* tw, uint32_t* th); extern int _TIFFDataSize(TIFFDataType type); /*--: Rational2Double: Return size of TIFFSetGetFieldType in bytes. */ extern int _TIFFSetGetFieldSize(TIFFSetGetFieldType setgettype); -extern void _TIFFsetByteArray(void**, void*, uint32); +extern void _TIFFsetByteArray(void**, void*, uint32_t); extern void _TIFFsetString(char**, char*); -extern void _TIFFsetShortArray(uint16**, uint16*, uint32); -extern void _TIFFsetLongArray(uint32**, uint32*, uint32); -extern void _TIFFsetFloatArray(float**, float*, uint32); -extern void _TIFFsetDoubleArray(double**, double*, uint32); +extern void _TIFFsetShortArray(uint16_t**, uint16_t*, uint32_t); +extern void _TIFFsetLongArray(uint32_t**, uint32_t*, uint32_t); +extern void _TIFFsetFloatArray(float**, float*, uint32_t); +extern void _TIFFsetDoubleArray(double**, double*, uint32_t); extern void _TIFFprintAscii(FILE*, const char*); extern void _TIFFprintAsciiTag(FILE*, const char*, const char*); @@ -386,30 +358,30 @@ extern TIFFErrorHandler _TIFFerrorHandler; extern TIFFErrorHandlerExt _TIFFwarningHandlerExt; extern TIFFErrorHandlerExt _TIFFerrorHandlerExt; -extern uint32 _TIFFMultiply32(TIFF*, uint32, uint32, const char*); -extern uint64 _TIFFMultiply64(TIFF*, uint64, uint64, const char*); +extern uint32_t _TIFFMultiply32(TIFF*, uint32_t, uint32_t, const char*); +extern uint64_t _TIFFMultiply64(TIFF*, uint64_t, uint64_t, const char*); extern tmsize_t _TIFFMultiplySSize(TIFF*, tmsize_t, tmsize_t, const char*); -extern tmsize_t _TIFFCastUInt64ToSSize(TIFF*, uint64, const char*); +extern tmsize_t _TIFFCastUInt64ToSSize(TIFF*, uint64_t, const char*); extern void* _TIFFCheckMalloc(TIFF*, tmsize_t, tmsize_t, const char*); extern void* _TIFFCheckRealloc(TIFF*, void*, tmsize_t, tmsize_t, const char*); -extern double _TIFFUInt64ToDouble(uint64); -extern float _TIFFUInt64ToFloat(uint64); +extern double _TIFFUInt64ToDouble(uint64_t); +extern float _TIFFUInt64ToFloat(uint64_t); extern float _TIFFClampDoubleToFloat(double); extern tmsize_t -_TIFFReadEncodedStripAndAllocBuffer(TIFF* tif, uint32 strip, +_TIFFReadEncodedStripAndAllocBuffer(TIFF* tif, uint32_t strip, void **buf, tmsize_t bufsizetoalloc, tmsize_t size_to_read); extern tmsize_t -_TIFFReadEncodedTileAndAllocBuffer(TIFF* tif, uint32 tile, - void **buf, tmsize_t bufsizetoalloc, - tmsize_t size_to_read); +_TIFFReadEncodedTileAndAllocBuffer(TIFF* tif, uint32_t tile, + void **buf, tmsize_t bufsizetoalloc, + tmsize_t size_to_read); extern tmsize_t _TIFFReadTileAndAllocBuffer(TIFF* tif, void **buf, tmsize_t bufsizetoalloc, - uint32 x, uint32 y, uint32 z, uint16 s); + uint32_t x, uint32_t y, uint32_t z, uint16_t s); extern int _TIFFSeekOK(TIFF* tif, toff_t off); extern int TIFFInitDumpMode(TIFF*, int); @@ -448,6 +420,9 @@ extern int TIFFInitPixarLog(TIFF*, int); #ifdef LOGLUV_SUPPORT extern int TIFFInitSGILog(TIFF*, int); #endif +#ifdef LERC_SUPPORT +extern int TIFFInitLERC(TIFF* tif, int); +#endif #ifdef LZMA_SUPPORT extern int TIFFInitLZMA(TIFF*, int); #endif @@ -457,11 +432,7 @@ extern int TIFFInitZSTD(TIFF*, int); #ifdef WEBP_SUPPORT extern int TIFFInitWebP(TIFF*, int); #endif -#ifdef VMS extern const TIFFCodec _TIFFBuiltinCODECS[]; -#else -extern TIFFCodec _TIFFBuiltinCODECS[]; -#endif #if defined(__cplusplus) } diff --git a/tiff/libtiff/tiffvers.h b/tiff/libtiff/tiffvers.h index 0cce798b..dbe55961 100644 --- a/tiff/libtiff/tiffvers.h +++ b/tiff/libtiff/tiffvers.h @@ -1,4 +1,4 @@ -#define TIFFLIB_VERSION_STR "LIBTIFF, Version 4.2.0\nCopyright (c) 1988-1996 Sam Leffler\nCopyright (c) 1991-1996 Silicon Graphics, Inc." +#define TIFFLIB_VERSION_STR "LIBTIFF, Version 4.3.0\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 20201219 +#define TIFFLIB_VERSION 20210416 |